Skip to content
This repository was archived by the owner on Jun 7, 2025. It is now read-only.

Commit 8073f19

Browse files
committed
Add base systems
1 parent 4eb7fdc commit 8073f19

File tree

6 files changed

+74
-40
lines changed

6 files changed

+74
-40
lines changed

flake.nix

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,19 @@
6969
});
7070
mkNixOSConfig = host: import ./system (inputs // {conf = importHostConf host;});
7171
in {
72-
nixosConfigurations = builtins.listToAttrs (map (host: {
73-
name = host;
74-
value = mkNixOSConfig host;
75-
})
76-
hosts);
72+
nixosConfigurations = builtins.listToAttrs (lib.flatten (map (host: let
73+
config = mkNixOSConfig host;
74+
in [
75+
{
76+
name = host;
77+
value = config.full;
78+
}
79+
{
80+
name = "${host}-base";
81+
value = config.base;
82+
}
83+
])
84+
hosts));
7785
packages = eachDefaultSystem (
7886
system: let
7987
pkgs = import nixpkgs {inherit system;};

system/base.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{pkgs, ...}: {
2+
users.mutableUsers = false;
3+
users.users.root.password = "nixos";
4+
5+
environment.systemPackages = with pkgs; [
6+
vim
7+
git
8+
];
9+
}

system/common.nix

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
conf,
23
nixpkgs,
34
pkgs,
45
...
@@ -12,14 +13,16 @@
1213
${pkgs.buildPackages.ckbcomp}/bin/ckbcomp -layout de -option ctrl:swapcaps -variant nodeadkeys > $out
1314
'';
1415

16+
networking.hostName = conf.hostname;
17+
networking.networkmanager = {
18+
enable = true;
19+
wifi.macAddress = "random";
20+
ethernet.macAddress = "random";
21+
};
22+
1523
programs.zsh.enable = true;
1624
users.defaultUserShell = pkgs.zsh;
1725

18-
environment.variables = {
19-
EDITOR = "hx";
20-
VISUAL = "hx";
21-
};
22-
2326
environment.systemPackages = with pkgs; [
2427
age
2528
comma

system/default.nix

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,21 @@
1919
}) (filterAttrs (k: _: hasPrefix "nixpkgs-" k) inputs);
2020

2121
specialArgs = inputs // extra-pkgs;
22-
in
23-
nixpkgs.lib.nixosSystem rec {
22+
in {
23+
base = nixpkgs.lib.nixosSystem {
24+
inherit system pkgs specialArgs;
25+
modules = [
26+
./common.nix
27+
conf.extraConfig
28+
conf.hardware-configuration
29+
30+
./base.nix
31+
./boot.nix
32+
./filesystems.nix
33+
];
34+
};
35+
36+
full = nixpkgs.lib.nixosSystem {
2437
inherit system pkgs specialArgs;
2538
modules = [
2639
./common.nix
@@ -33,6 +46,7 @@ in
3346
./boot.nix
3447
./borg.nix
3548
./emulation.nix
49+
./env.nix
3650
./filesystems.nix
3751
./fonts.nix
3852
./geoclue2.nix
@@ -58,4 +72,5 @@ in
5872
};
5973
}
6074
];
61-
}
75+
};
76+
}

system/env.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
environment.variables = {
3+
EDITOR = "hx";
4+
VISUAL = "hx";
5+
};
6+
}

system/networking.nix

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,28 @@
33
pkgs,
44
...
55
}: {
6-
networking.hostName = conf.hostname;
6+
networking.networkmanager.dispatcherScripts = [
7+
{
8+
type = "basic";
9+
source = let
10+
inherit (conf.networking) vpn;
11+
wifi.trusted = builtins.toFile "wifi-trusted" (builtins.foldl' (acc: x: "${acc}${x}\n") "" conf.networking.wifi.trusted);
12+
in
13+
pkgs.writeText "trusted-networks" ''
14+
export PATH=${pkgs.lib.makeBinPath (with pkgs; [coreutils gnugrep networkmanager])}
715
8-
networking.networkmanager = {
9-
enable = true;
10-
wifi.macAddress = "random";
11-
ethernet.macAddress = "random";
12-
dispatcherScripts = [
13-
{
14-
type = "basic";
15-
source = let
16-
inherit (conf.networking) vpn;
17-
wifi.trusted = builtins.toFile "wifi-trusted" (builtins.foldl' (acc: x: "${acc}${x}\n") "" conf.networking.wifi.trusted);
18-
in
19-
pkgs.writeText "trusted-networks" ''
20-
export PATH=${pkgs.lib.makeBinPath (with pkgs; [coreutils gnugrep networkmanager])}
21-
22-
if [[ -z "$1" ]] || [[ "$1" = "vpn" ]]; then
23-
exit
24-
fi
16+
if [[ -z "$1" ]] || [[ "$1" = "vpn" ]]; then
17+
exit
18+
fi
2519
26-
if nmcli --fields=UUID c s --active | tail +2 | cut -d' ' -f1 | sort | comm -12 - <(sort ${wifi.trusted}) | grep -q .; then
27-
nmcli c up "${vpn.default}" &
28-
else
29-
nmcli c up "${vpn.full}" &
30-
fi
31-
'';
32-
}
33-
];
34-
};
20+
if nmcli --fields=UUID c s --active | tail +2 | cut -d' ' -f1 | sort | comm -12 - <(sort ${wifi.trusted}) | grep -q .; then
21+
nmcli c up "${vpn.default}" &
22+
else
23+
nmcli c up "${vpn.full}" &
24+
fi
25+
'';
26+
}
27+
];
3528

3629
networking.firewall = {
3730
enable = true;

0 commit comments

Comments
 (0)