Commit 07c1873201c8

Vincent Demeester <vincent@sbr.pm>
2020-04-05 10:17:22
Makefile: add /etc/nixos check …
… and dry-build. Also commit home.nix to read hostname file to load the correct file (like what is done on nixos-configuration) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 405b2f3
Changed files (5)
machines/base.nix
@@ -1,7 +1,6 @@
-{ pkgs, ...}:
+{ pkgs, ... }:
 
 {
-  imports = [ ../modules/module-list.nix ];
   programs = {
     home-manager = {
       enable = true;
@@ -22,12 +21,17 @@
   ];
   xdg.configFile."nr/default" = {
     text = builtins.toJSON [
-      {cmd = "ncdu";} {cmd = "sshfs";} {cmd = "gotop";} {cmd = "pandoc";}
-      {cmd = "dust"; pkg = "du-dust";} { cmd = "bandwhich";}
-      {cmd = "lspci"; pkg = "pciutils";} {cmd = "lsusb"; pkg = "usbutils";}
-      {cmd = "9"; pkg = "plan9port"; }
-      {cmd = "wakeonlan"; pkg = "python36Packages.wakeonlan";}
-      {cmd = "beet"; pkg = "beets";}
+      { cmd = "ncdu"; }
+      { cmd = "sshfs"; }
+      { cmd = "gotop"; }
+      { cmd = "pandoc"; }
+      { cmd = "dust"; pkg = "du-dust"; }
+      { cmd = "bandwhich"; }
+      { cmd = "lspci"; pkg = "pciutils"; }
+      { cmd = "lsusb"; pkg = "usbutils"; }
+      { cmd = "9"; pkg = "plan9port"; }
+      { cmd = "wakeonlan"; pkg = "python36Packages.wakeonlan"; }
+      { cmd = "beet"; pkg = "beets"; }
     ];
     onChange = "${pkgs.nur.repos.vdemeester.nr}/bin/nr default";
   };
tmp/nixos-configuration/configuration.nix
@@ -3,7 +3,6 @@
 # configuration.
 
 { config, pkgs, ... }:
-
 let
   hostName = "${builtins.readFile ./hostname}";
 in
@@ -16,8 +15,6 @@ rec {
     # Machine specific configuration files
     (./machine + "/${hostName}.nix")
   ];
-  
+
   networking.hostName = "${hostName}";
 }
-
-
.gitignore
@@ -1,6 +1,6 @@
 *~
 result
-home.nix
+hostname
 *.retry
 assets/machines.nix
 docs/sitemap.org
\ No newline at end of file
home.nix
@@ -0,0 +1,11 @@
+let
+  hostName = "${builtins.readFile ./hostname}";
+in
+rec {
+  imports = [
+    # Default profile with default configuration
+    ./modules/module-list.nix
+    # Machine specific configuration files
+    (./machines + "/${hostName}.nix")
+  ];
+}
Makefile
@@ -8,6 +8,7 @@ endif
 
 DOTEMACS = ~/.config/emacs
 DOTNIXPKGS = ~/.config/nixpkgs
+ETCNIXOS = /etc/nixos
 SYNCDIR = ~/sync/nixos
 PUBLISH_FOLDER = ~/desktop/sites/beta.sbr.pm
 
@@ -30,7 +31,7 @@ assets:
 	cp -Rv ~/sync/nixos/machines.nix assets/
 
 .PHONY: build
-build: assets
+build: assets setup
 	@if test $(USER) = root;\
 	then\
 		nixos-rebuild build;\
@@ -38,8 +39,15 @@ build: assets
 		home-manager build;\
 	fi
 
+.PHONY: dry-build
+dry-build: assets setup
+	@if test $(USER) = root;\
+	then\
+		nixos-rebuild dry-build;\
+	fi
+
 .PHONY: switch
-switch: assets
+switch: assets setup
 	@if test $(USER) = root;\
 	then\
 		nixos-rebuild build;\
@@ -79,8 +87,7 @@ doctor:
 	@readlink $(DOTNIXPKGS) || $(error $(DOTNIXPKGS) is not correctly linked, you may need to run setup)
 
 .PHONY: setup
-setup: $(DOTEMACS) $(DOTNIXPKGS) $(SYNCDIR)
-	@echo $(USER)
+setup: $(DOTEMACS) $(DOTNIXPKGS) $(ETCNIXOS) $(SYNCDIR)
 
 $(DOTEMACS):
 	@echo "Link $(DOTEMACS) to $(CURDIR)/tools/emacs"
@@ -90,5 +97,12 @@ $(DOTNIXPKGS):
 	@echo "Link $(DOTNIXPKGS) to $(CURDIR)"
 	@ln -s $(CURDIR) $(DOTNIXPKGS)
 
+$(ETCNIXOS):
+	@if test $(USER) = root;\
+	then\
+		echo "Link $(ETCNIXOS) $(CURDIR)";\
+		ln -s $(CURDIR) $(ETCNIXOS);\
+	fi
+
 $(SYNCDIR):
 	$(error $(SYNCDIR) is not present, you need to configure syncthing before running this command)