Skip to content

Commit 893711f

Browse files
refactor(nixos): refactor config into common modules and use unfreepredicate
1 parent b1dc9c2 commit 893711f

13 files changed

Lines changed: 207 additions & 149 deletions

File tree

configurations/nixos/lab/default.nix

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# This file is just *top-level* configuration.
33
{
44
inputs,
5-
pkgs,
6-
userConfigs,
75
...
86
}:
97
{
@@ -29,35 +27,6 @@
2927
./services
3028
];
3129

32-
# Need to enable zsh before we can actually use it. Home manager configs it,
33-
# but cannot set the login shell because that's root level operation
34-
programs.zsh.enable = true;
35-
36-
users.users =
37-
let
38-
helper =
39-
acc:
40-
{ username, initialHashedPassword, ... }:
41-
{
42-
${username} = {
43-
# If you do, you can skip setting a root password by passing
44-
# '--no-root-passwd' to nixos-install. Be sure to change it (using
45-
# passwd) after rebooting!
46-
inherit initialHashedPassword;
47-
48-
isNormalUser = true;
49-
extraGroups = [
50-
"wheel"
51-
"docker"
52-
"libvirtd"
53-
];
54-
shell = pkgs.zsh;
55-
};
56-
}
57-
// acc;
58-
in
59-
builtins.foldl' helper { } userConfigs;
60-
6130
# This option defines the first version of NixOS you have installed on this particular machine,
6231
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
6332
#
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ pkgs, userConfigs, ... }:
2+
{
3+
# Need to enable zsh before we can actually use it. Home manager configs it,
4+
# but cannot set the login shell because that's root level operation
5+
programs.zsh.enable = true;
6+
7+
users.users =
8+
let
9+
helper =
10+
acc:
11+
{ username, initialHashedPassword, ... }:
12+
{
13+
${username} = {
14+
# If you do, you can skip setting a root password by passing
15+
# '--no-root-passwd' to nixos-install. Be sure to change it (using
16+
# passwd) after rebooting!
17+
inherit initialHashedPassword;
18+
19+
isNormalUser = true;
20+
extraGroups = [
21+
"wheel"
22+
"docker"
23+
"libvirtd"
24+
];
25+
shell = pkgs.zsh;
26+
};
27+
}
28+
// acc;
29+
in
30+
builtins.foldl' helper { } userConfigs;
31+
32+
}

configurations/nixos/legion/default.nix

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
# This file is just *top-level* configuration.
33
{
44
inputs,
5-
pkgs,
6-
lib,
7-
userConfigs,
85
...
96
}:
107
{
@@ -29,56 +26,6 @@
2926
./system
3027
];
3128

32-
nixpkgs = {
33-
config = {
34-
# enable builds with cuda support!
35-
cudaSupport = true;
36-
};
37-
};
38-
39-
# Need to enable zsh before we can actually use it. Home manager configs it,
40-
# but cannot set the login shell because that's root level operation
41-
programs.zsh.enable = true;
42-
43-
users.users =
44-
let
45-
helper =
46-
acc:
47-
{ username, initialHashedPassword, ... }:
48-
{
49-
${username} = {
50-
# If you do, you can skip setting a root password by passing
51-
# '--no-root-passwd' to nixos-install. Be sure to change it (using
52-
# passwd) after rebooting!
53-
inherit initialHashedPassword;
54-
55-
isNormalUser = true;
56-
extraGroups = [
57-
"wheel"
58-
"docker"
59-
"libvirtd"
60-
];
61-
shell = pkgs.zsh;
62-
};
63-
}
64-
// acc;
65-
in
66-
builtins.foldl' helper { } userConfigs;
67-
68-
nixpkgs.overlays = [
69-
# https://github.com/NixOS/nixpkgs/issues/388681
70-
# TODO:remove when fixed for legion build (open-webui is broken i think)
71-
(_: prev: {
72-
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
73-
(_: python-prev: {
74-
onnxruntime = python-prev.onnxruntime.overridePythonAttrs (oldAttrs: {
75-
buildInputs = lib.lists.remove pkgs.onnxruntime oldAttrs.buildInputs;
76-
});
77-
})
78-
];
79-
})
80-
];
81-
8229
# This option defines the first version of NixOS you have installed on this particular machine,
8330
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
8431
#
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{ lib, pkgs, ... }:
2+
{
3+
nixpkgs = {
4+
config = {
5+
# enable builds with cuda support!
6+
cudaSupport = true;
7+
allowUnfreePredicate =
8+
pkg:
9+
builtins.elem (lib.getName pkg) (
10+
# apps
11+
[
12+
"betterttv"
13+
"code"
14+
"discord"
15+
"obsidian"
16+
"spotify"
17+
"steam"
18+
"steam-unwrapped"
19+
"vscode"
20+
"vscode-extension-github-codespaces"
21+
"vscode-extension-ms-dotnettools-csharp"
22+
"vscode-extension-ms-vscode-cpptools"
23+
"vscode-extension-ms-vscode-remote-remote-containers"
24+
"vscode-extension-ms-vscode-remote-remote-ssh"
25+
"vscode-extension-ms-vscode-remote-remote-ssh-edit"
26+
]
27+
# nvidia
28+
++ [
29+
"cuda_cccl"
30+
"cuda_cudart"
31+
"cuda_cuobjdump"
32+
"cuda_cupti"
33+
"cuda_cuxxfilt"
34+
"cuda_gdb"
35+
"cuda-merged"
36+
"cuda_nvcc"
37+
"cuda_nvdisasm"
38+
"cuda_nvml_dev"
39+
"cuda_nvprune"
40+
"cuda_nvrtc"
41+
"cuda_nvtx"
42+
"cuda_profiler_api"
43+
"cuda_sanitizer_api"
44+
"cudnn"
45+
"libcublas"
46+
"libcufft"
47+
"libcurand"
48+
"libcusolver"
49+
"libcusparse"
50+
"libcusparse_lt"
51+
"libnpp"
52+
"libnvjitlink"
53+
"nvidia-x11"
54+
"nvidia-settings"
55+
]
56+
);
57+
};
58+
59+
overlays = [
60+
# https://github.com/NixOS/nixpkgs/issues/388681
61+
# TODO:remove when fixed for legion build (open-webui is broken i think)
62+
(_: prev: {
63+
pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
64+
(_: python-prev: {
65+
onnxruntime = python-prev.onnxruntime.overridePythonAttrs (oldAttrs: {
66+
buildInputs = lib.lists.remove pkgs.onnxruntime oldAttrs.buildInputs;
67+
});
68+
})
69+
];
70+
})
71+
];
72+
};
73+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ pkgs, userConfigs, ... }:
2+
{
3+
users.users =
4+
let
5+
helper =
6+
acc:
7+
{ username, initialHashedPassword, ... }:
8+
{
9+
${username} = {
10+
# If you do, you can skip setting a root password by passing
11+
# '--no-root-passwd' to nixos-install. Be sure to change it (using
12+
# passwd) after rebooting!
13+
inherit initialHashedPassword;
14+
15+
isNormalUser = true;
16+
extraGroups = [
17+
"wheel"
18+
"docker"
19+
"libvirtd"
20+
];
21+
shell = pkgs.zsh;
22+
};
23+
}
24+
// acc;
25+
in
26+
builtins.foldl' helper { } userConfigs;
27+
28+
# Need to enable zsh before we can actually use it. Home manager configs it,
29+
# but cannot set the login shell because that's root level operation
30+
programs.zsh.enable = true;
31+
32+
}

configurations/nixos/penguin/default.nix

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# This file is just *top-level* configuration.
33
{
44
inputs,
5-
pkgs,
6-
userConfigs,
75
...
86
}:
97
{
@@ -29,35 +27,6 @@
2927
./system
3028
];
3129

32-
# Need to enable zsh before we can actually use it. Home manager configs it,
33-
# but cannot set the login shell because that's root level operation
34-
programs.zsh.enable = true;
35-
36-
users.users =
37-
let
38-
helper =
39-
acc:
40-
{ username, initialHashedPassword, ... }:
41-
{
42-
${username} = {
43-
# If you do, you can skip setting a root password by passing
44-
# '--no-root-passwd' to nixos-install. Be sure to change it (using
45-
# passwd) after rebooting!
46-
inherit initialHashedPassword;
47-
48-
isNormalUser = true;
49-
extraGroups = [
50-
"wheel"
51-
"docker"
52-
"libvirtd"
53-
];
54-
shell = pkgs.zsh;
55-
};
56-
}
57-
// acc;
58-
in
59-
builtins.foldl' helper { } userConfigs;
60-
6130
# This option defines the first version of NixOS you have installed on this particular machine,
6231
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
6332
#
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{ lib, ... }:
2+
{
3+
nixpkgs.config.allowUnfreePredicate =
4+
pkg:
5+
builtins.elem (lib.getName pkg) [
6+
"betterttv"
7+
"obsidian"
8+
"spotify"
9+
];
10+
11+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{ pkgs, userConfigs, ... }:
2+
{
3+
users.users =
4+
let
5+
helper =
6+
acc:
7+
{ username, initialHashedPassword, ... }:
8+
{
9+
${username} = {
10+
# If you do, you can skip setting a root password by passing
11+
# '--no-root-passwd' to nixos-install. Be sure to change it (using
12+
# passwd) after rebooting!
13+
inherit initialHashedPassword;
14+
15+
isNormalUser = true;
16+
extraGroups = [ "wheel" ];
17+
shell = pkgs.zsh;
18+
};
19+
}
20+
// acc;
21+
in
22+
builtins.foldl' helper { } userConfigs;
23+
24+
# Need to enable zsh before we can actually use it. Home manager configs it,
25+
# but cannot set the login shell because that's root level operation
26+
programs.zsh.enable = true;
27+
}

configurations/nixos/pi/default.nix

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# This file is just *top-level* configuration.
33
{
44
inputs,
5-
pkgs,
65
...
76
}:
87
{
@@ -16,33 +15,6 @@
1615
./system
1716
];
1817

19-
users.users.justinhoang = {
20-
# If you do, you can skip setting a root password by passing
21-
# '--no-root-passwd' to nixos-install. Be sure to change it (using
22-
# passwd) after rebooting!
23-
initialHashedPassword = "$y$j9T$sXZCGwjtugZIt/C2nU8bk/$D36OrIe3eyGSM7rPysbQI1OyT56TdtJZtcvnOne2Ge0";
24-
isNormalUser = true;
25-
extraGroups = [ "wheel" ];
26-
};
27-
28-
# https://github.com/NixOS/nixpkgs/issues/154163#issuecomment-1350599022
29-
nixpkgs = {
30-
overlays = [
31-
(_: prev: {
32-
makeModulesClosure = x: prev.makeModulesClosure (x // { allowMissing = true; });
33-
})
34-
];
35-
};
36-
37-
environment.systemPackages =
38-
let
39-
inherit (pkgs.stdenv.hostPlatform) system;
40-
in
41-
[
42-
# add basic nixvim config
43-
inputs.nixvim-config.packages.${system}.minimal
44-
];
45-
4618
# This option defines the first version of NixOS you have installed on this particular machine,
4719
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
4820
#
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
# https://github.com/NixOS/nixpkgs/issues/154163#issuecomment-1350599022
3+
nixpkgs = {
4+
overlays = [
5+
(_: prev: {
6+
makeModulesClosure = x: prev.makeModulesClosure (x // { allowMissing = true; });
7+
})
8+
];
9+
};
10+
}

0 commit comments

Comments
 (0)