lol

nixos/etc.nix: Make independent

(cherry picked from commit 56c283e5c8dfd4d8d5daa15dfa3896beef2ac012)

+87 -4
+1 -1
nixos/modules/module-list.nix
··· 1157 1157 ./system/boot/systemd-nspawn.nix 1158 1158 ./system/boot/timesyncd.nix 1159 1159 ./system/boot/tmp.nix 1160 - ./system/etc/etc.nix 1160 + ./system/etc/etc-activation.nix 1161 1161 ./tasks/auto-upgrade.nix 1162 1162 ./tasks/bcache.nix 1163 1163 ./tasks/cpu-freq.nix
+12
nixos/modules/system/etc/etc-activation.nix
··· 1 + { config, lib, ... }: 2 + let 3 + inherit (lib) stringAfter; 4 + in { 5 + 6 + imports = [ ./etc.nix ]; 7 + 8 + config = { 9 + system.activationScripts.etc = 10 + stringAfter [ "users" "groups" ] config.system.build.etcActivationCommands; 11 + }; 12 + }
+3 -3
nixos/modules/system/etc/etc.nix
··· 66 66 67 67 { 68 68 69 + imports = [ ../build.nix ]; 70 + 69 71 ###### interface 70 72 71 73 options = { ··· 188 190 config = { 189 191 190 192 system.build.etc = etc; 191 - 192 - system.activationScripts.etc = stringAfter [ "users" "groups" ] 193 + system.build.etcActivationCommands = 193 194 '' 194 195 # Set up the statically computed bits of /etc. 195 196 echo "setting up /etc..." 196 197 ${pkgs.perl.withPackages (p: [ p.FileSlurp ])}/bin/perl ${./setup-etc.pl} ${etc}/etc 197 198 ''; 198 - 199 199 }; 200 200 201 201 }
+70
nixos/modules/system/etc/test.nix
··· 1 + { lib 2 + , coreutils 3 + , fakechroot 4 + , fakeroot 5 + , evalMinimalConfig 6 + , pkgsModule 7 + , runCommand 8 + , util-linux 9 + , vmTools 10 + , writeText 11 + }: 12 + let 13 + node = evalMinimalConfig ({ config, ... }: { 14 + imports = [ pkgsModule ../etc/etc.nix ]; 15 + environment.etc."passwd" = { 16 + text = passwdText; 17 + }; 18 + environment.etc."hosts" = { 19 + text = hostsText; 20 + mode = "0751"; 21 + }; 22 + }); 23 + passwdText = '' 24 + root:x:0:0:System administrator:/root:/run/current-system/sw/bin/bash 25 + ''; 26 + hostsText = '' 27 + 127.0.0.1 localhost 28 + ::1 localhost 29 + # testing... 30 + ''; 31 + in 32 + lib.recurseIntoAttrs { 33 + test-etc-vm = 34 + vmTools.runInLinuxVM (runCommand "test-etc-vm" { } '' 35 + mkdir -p /etc 36 + ${node.config.system.build.etcActivationCommands} 37 + set -x 38 + [[ -L /etc/passwd ]] 39 + diff /etc/passwd ${writeText "expected-passwd" passwdText} 40 + [[ 751 = $(stat --format %a /etc/hosts) ]] 41 + diff /etc/hosts ${writeText "expected-hosts" hostsText} 42 + set +x 43 + touch $out 44 + ''); 45 + 46 + # fakeroot is behaving weird 47 + test-etc-fakeroot = 48 + runCommand "test-etc" 49 + { 50 + nativeBuildInputs = [ 51 + fakeroot 52 + fakechroot 53 + # for chroot 54 + coreutils 55 + # fakechroot needs getopt, which is provided by util-linux 56 + util-linux 57 + ]; 58 + fakeRootCommands = '' 59 + mkdir -p /etc 60 + ${node.config.system.build.etcActivationCommands} 61 + diff /etc/hosts ${writeText "expected-hosts" hostsText} 62 + touch $out 63 + ''; 64 + } '' 65 + mkdir fake-root 66 + export FAKECHROOT_EXCLUDE_PATH=/dev:/proc:/sys:${builtins.storeDir}:$out 67 + fakechroot fakeroot chroot $PWD/fake-root bash -c 'source $stdenv/setup; eval "$fakeRootCommands"' 68 + ''; 69 + 70 + }
+1
nixos/tests/all-tests.nix
··· 140 140 env = handleTest ./env.nix {}; 141 141 ergo = handleTest ./ergo.nix {}; 142 142 ergochat = handleTest ./ergochat.nix {}; 143 + etc = pkgs.callPackage ../modules/system/etc/test.nix { inherit evalMinimalConfig; }; 143 144 etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {}; 144 145 etcd-cluster = handleTestOn ["x86_64-linux"] ./etcd-cluster.nix {}; 145 146 etebase-server = handleTest ./etebase-server.nix {};