commit 07c1873201c87e73ab92beb41d7712680cba67c7
parent 405b2f35ad856a701633077cea9aaf36058cd9b0
Author: Vincent Demeester <vincent@sbr.pm>
Date: Sun, 5 Apr 2020 10:17:22 +0200
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>
Diffstat:
5 files changed, 43 insertions(+), 17 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,6 +1,6 @@
*~
result
-home.nix
+hostname
*.retry
assets/machines.nix
docs/sitemap.org
\ No newline at end of file
diff --git a/Makefile b/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)
diff --git a/home.nix b/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")
+ ];
+}
diff --git a/machines/base.nix b/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";
};
diff --git a/tmp/nixos-configuration/configuration.nix b/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}";
}
-
-