about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--README.org17
-rw-r--r--flake.lock64
-rw-r--r--flake.nix149
-rw-r--r--hosts/aptos/default.nix9
-rw-r--r--hosts/carmel/default.nix10
-rw-r--r--hosts/tahoe/default.nix3
-rw-r--r--nix/checks.nix31
-rw-r--r--nix/default.nix5
-rw-r--r--nix/mkHomeManagerConfiguration.nix28
-rw-r--r--nix/mkSystem.nix7
10 files changed, 191 insertions, 132 deletions
diff --git a/README.org b/README.org
index 39660ed..9e59a75 100644
--- a/README.org
+++ b/README.org
@@ -1,7 +1,22 @@
 #+TITLE: world - nix configuration
 
 * nixos
-To rebuild the host and home-manager:
+To rebuild the host:
 #+begin_src sh
 sudo nixos-rebuild switch  --flake .
 #+end_src
+
+or
+#+begin_src sh
+nix-rebuild-host
+#+end_src
+* home-manager
+To rebuild the configuration for =home-manager=:
+#+begin_src sh
+home-manager switch --flake .
+#+end_src
+* update flakes
+To update the flakes:
+#+begin_src sh
+nix flake update
+#+end_src
diff --git a/flake.lock b/flake.lock
index 3d07120..cfd012e 100644
--- a/flake.lock
+++ b/flake.lock
@@ -7,11 +7,11 @@
         ]
       },
       "locked": {
-        "lastModified": 1652712410,
-        "narHash": "sha256-hMJ2TqLt0DleEnQFGUHK9sV2aAzJPU8pZeiZoqRozbE=",
+        "lastModified": 1662241716,
+        "narHash": "sha256-urqPvSvvGUhkwzTDxUI8N1nsdMysbAfjmBNZaTYBZRU=",
         "owner": "ryantm",
         "repo": "agenix",
-        "rev": "7e5e58b98c3dcbf497543ff6f22591552ebfe65b",
+        "rev": "c96da5835b76d3d8e8d99a0fec6fe32f8539ee2e",
         "type": "github"
       },
       "original": {
@@ -26,11 +26,11 @@
         "nixpkgs": "nixpkgs"
       },
       "locked": {
-        "lastModified": 1654803545,
-        "narHash": "sha256-XV0gxr2looaXOKbzGn+BZsCh1NsCq7rti1ooYql6Y9g=",
+        "lastModified": 1663700519,
+        "narHash": "sha256-OA7fE3bsG81Sr3XC0tbKlkQqdCNglv1WlmEnUOvnHlI=",
         "owner": "nix-community",
         "repo": "emacs-overlay",
-        "rev": "cf5a17b22ffd987e24770d33b5b59ea496eeac49",
+        "rev": "8e54a8980aa438c4f35807ad676acbf7578acce3",
         "type": "github"
       },
       "original": {
@@ -41,11 +41,11 @@
     },
     "flake-utils": {
       "locked": {
-        "lastModified": 1653893745,
-        "narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
+        "lastModified": 1659877975,
+        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
         "owner": "numtide",
         "repo": "flake-utils",
-        "rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
+        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
         "type": "github"
       },
       "original": {
@@ -71,11 +71,11 @@
     },
     "futils": {
       "locked": {
-        "lastModified": 1656065134,
-        "narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
+        "lastModified": 1659877975,
+        "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
         "owner": "numtide",
         "repo": "flake-utils",
-        "rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
+        "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
         "type": "github"
       },
       "original": {
@@ -91,11 +91,11 @@
         ]
       },
       "locked": {
-        "lastModified": 1654113405,
-        "narHash": "sha256-VpK+0QaWG2JRgB00lw77N9TjkE3ec0iMYIX1TzGpxa4=",
+        "lastModified": 1656169755,
+        "narHash": "sha256-Nlnm4jeQWEGjYrE6hxi/7HYHjBSZ/E0RtjCYifnNsWk=",
         "owner": "nix-community",
         "repo": "home-manager",
-        "rev": "ac2287df5a2d6f0a44bbcbd11701dbbf6ec43675",
+        "rev": "4a3d01fb53f52ac83194081272795aa4612c2381",
         "type": "github"
       },
       "original": {
@@ -108,8 +108,8 @@
     "nixpkgs": {
       "locked": {
         "lastModified": 0,
-        "narHash": "sha256-EFkgVkHuPFuzd8L5W81fZR5YEbfHirh3uDMk3xhQmhc=",
-        "path": "/nix/store/s7w8mfm95yylaxp5vp0dh1f9w59grfk8-source",
+        "narHash": "sha256-/l1HI2tFLihda6yh+j848GlRDVUiSJPr+yzA7ip8Z84=",
+        "path": "/nix/store/wi84fkkl5lq0bmf7c1jycax5vrw7fl6s-source",
         "type": "path"
       },
       "original": {
@@ -119,11 +119,11 @@
     },
     "nixpkgs-unstable": {
       "locked": {
-        "lastModified": 1654694478,
-        "narHash": "sha256-nFAMETXEhIrqnBe28u6vqy4ixSRr0BRrlZLlS0e7eoM=",
+        "lastModified": 1663634720,
+        "narHash": "sha256-wMYXWKgysznBUHmvq5fN0uzUTNpnBLREPupM17xP8MY=",
         "owner": "nixos",
         "repo": "nixpkgs",
-        "rev": "18de53ca965bd0678aaf09e5ce0daae05c58355a",
+        "rev": "998f0f7924198b2460458728de59fe738997f28e",
         "type": "github"
       },
       "original": {
@@ -135,11 +135,11 @@
     },
     "nixpkgs_2": {
       "locked": {
-        "lastModified": 1658355931,
-        "narHash": "sha256-/l1HI2tFLihda6yh+j848GlRDVUiSJPr+yzA7ip8Z84=",
+        "lastModified": 1663707118,
+        "narHash": "sha256-eyzwPTQqB9l/viI769epK8NwGOY8v/c2TNrRmcX5u+8=",
         "owner": "nixos",
         "repo": "nixpkgs",
-        "rev": "d2ff0167ce734340e745ca1f53b11a0996ff17a4",
+        "rev": "cafad185b7486732d6b6e0b8447588e22216c020",
         "type": "github"
       },
       "original": {
@@ -151,11 +151,11 @@
     },
     "nur": {
       "locked": {
-        "lastModified": 1654815884,
-        "narHash": "sha256-mmYhB+fl2dabl8Osm4d0vHKLxISH+lL4tAG9bsrnuIQ=",
+        "lastModified": 1663698372,
+        "narHash": "sha256-mwbkSx0g/U73DzpxkRL7KuXZtS7rZt5Ks4BbxsftHrY=",
         "owner": "nix-community",
         "repo": "NUR",
-        "rev": "d52f3d30fa7d0672844941450ba07159f4b30f8b",
+        "rev": "8c17e0445fe26f7d44c100f478a5855cd0385d5b",
         "type": "github"
       },
       "original": {
@@ -174,11 +174,11 @@
         ]
       },
       "locked": {
-        "lastModified": 1656169028,
-        "narHash": "sha256-y9DRauokIeVHM7d29lwT8A+0YoGUBXV3H0VErxQeA8s=",
+        "lastModified": 1663082609,
+        "narHash": "sha256-lmCCIu4dj59qbzkGKHQtolhpIEQMeAd2XUbXVPqgPYo=",
         "owner": "cachix",
         "repo": "pre-commit-hooks.nix",
-        "rev": "db3bd555d3a3ceab208bed48f983ccaa6a71a25e",
+        "rev": "60cad1a326df17a8c6cf2bb23436609fdd83024e",
         "type": "github"
       },
       "original": {
@@ -209,11 +209,11 @@
         ]
       },
       "locked": {
-        "lastModified": 1661136859,
-        "narHash": "sha256-o3y1elFGRs/9kqaIeziAnTy9lIWA6VHtQfq0ARRVO2A=",
+        "lastModified": 1663642835,
+        "narHash": "sha256-xzIWFhLR7iws7ZIu5iHlbyY5bhGQTFECf+XKEjbjwpk=",
         "owner": "oxalica",
         "repo": "rust-overlay",
-        "rev": "6d1418192be90968acfa25e7d7b089e246eb15c4",
+        "rev": "c9cfed9847475dcfc8b821d6ccb0c5229b4130a1",
         "type": "github"
       },
       "original": {
diff --git a/flake.nix b/flake.nix
index 125e214..f659025 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,14 +2,11 @@
   description = "personal NixOS configurations";
 
   inputs = {
-    # Nixpkgs, NixOS's official repo
     nixpkgs.url = "github:nixos/nixpkgs/release-22.05";
+    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
 
     futils.url = "github:numtide/flake-utils";
 
-    # We use the unstable nixpkgs repo for some packages.
-    nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
-
     emacs-overlay.url = "github:nix-community/emacs-overlay";
 
     agenix = {
@@ -43,52 +40,120 @@
   };
 
   # Output config, or config for NixOS system
-  outputs = { self, pre-commit-hooks, ... }@inputs:
+  outputs = inputs@{ self, ... }:
     let
-      inherit (inputs.futils.lib) eachSystem system;
-      mySystems = [ system.x86_64-linux ];
-      eachMySystem = eachSystem mySystems;
-      lib = import ./nix { inherit inputs; };
+      myLib = import ./nix inputs;
+      lib = inputs.nixpkgs.lib // builtins;
+      supportedSystems = [ "x86_64-linux" ];
+      forAllSystems = lib.genAttrs supportedSystems;
+
+      # Nixpkgs instantiated for supported system types.
+      nixpkgsFor = forAllSystems (system:
+        import inputs.nixpkgs {
+          inherit system;
+          config = { allowUnfree = true; };
+        });
     in
-    eachMySystem
-      (system:
-        let
-          pkgs = import inputs.nixpkgs { inherit system; };
-          home-manager = inputs.home-manager.defaultPackage."${system}";
+    {
+      checks = forAllSystems (system:
+        let pkgs = nixpkgsFor.${system};
         in
-        rec {
-          packages = pkgs // {
-            inherit home-manager;
+        {
+          pre-commit-check = inputs.pre-commit-hooks.lib."${system}".run {
+            src = ./.;
+            hooks = {
+              nixpkgs-fmt.enable = true;
+              terraform-format.enable = true;
+              trailing-whitespace = {
+                enable = true;
+                entry =
+                  "${pkgs.python3Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer";
+                types = [ "text" ];
+              };
 
-            tools = import ./tools { inherit pkgs; };
-            ops = import ./ops { inherit pkgs; };
-            users.fcuny = import ./users/fcuny { inherit pkgs; };
-          };
+              end-of-file-fixer = {
+                enable = true;
+                entry =
+                  "${pkgs.python3Packages.pre-commit-hooks}/bin/end-of-file-fixer";
+                types = [ "text" ];
+              };
+
+              check-executables-have-shebangs = {
+                entry =
+                  "${pkgs.python3Packages.pre-commit-hooks}/check-executables-have-shebangs";
+                types = [ "text" "executable" ];
+              };
+
+              check-json = {
+                enable = true;
+                entry = "${pkgs.python3Packages.pre-commit-hooks}/check-json";
+                types = [ "json" ];
+              };
+
+              check-toml = {
+                enable = true;
+                entry = "${pkgs.python3Packages.pre-commit-hooks}/check-toml";
+                types = [ "toml" ];
+              };
 
-          checks = import ./nix/checks.nix { inherit pkgs pre-commit-hooks; };
-
-          devShells = {
-            default = pkgs.mkShell {
-              name = "NixOS-config";
-              buildInputs = with pkgs; [
-                gitAndTools.pre-commit
-                nixUnstable
-                nixfmt
-                nixpkgs-fmt
-                rnix-lsp
-                home-manager
-                git
-                go
-                gopls
-              ];
-              inherit (self.checks.${system}.pre-commit-check) shellHook;
+              check-yaml = {
+                enable = true;
+                entry = "${pkgs.python3Packages.pre-commit-hooks}/check-yaml";
+                types = [ "yaml" ];
+              };
+
+              shellcheck = {
+                enable = true;
+                files = "\\.sh$";
+                types_or = [ "file" ];
+              };
             };
           };
-        }) // {
+        });
+
+      devShells = forAllSystems (system: {
+        default = inputs.nixpkgs.legacyPackages.${system}.mkShell {
+          name = "fcuny-configuration-on-${system}-system";
+          buildInputs = with inputs.nixpkgs.legacyPackages.${system}.pkgs; [
+            gitAndTools.pre-commit
+            nixfmt
+            nixpkgs-fmt
+            rnix-lsp
+            home-manager
+            git
+            nixos-rebuild
+          ];
+          inherit (self.checks.${system}.pre-commit-check) shellHook;
+        };
+      });
+
       nixosConfigurations = {
-        carmel = lib.mkSystem { hostname = "carmel"; };
-        aptos = lib.mkSystem { hostname = "aptos"; };
-        tahoe = lib.mkSystem { hostname = "tahoe"; };
+        aptos = myLib.mkSystem { hostname = "aptos"; };
+        carmel = myLib.mkSystem { hostname = "carmel"; };
+        tahoe = myLib.mkSystem { hostname = "tahoe"; };
+      };
+
+      homeConfigurations = {
+        useGlobalPkgs = true;
+        useUserPackages = true;
+
+        "fcuny@aptos" =
+          myLib.mkHomeManagerConfiguration { hostname = "aptos"; };
+
+        "fcuny@tahoe" =
+          myLib.mkHomeManagerConfiguration { hostname = "tahoe"; };
       };
     };
+  # in eachMySystem (system:
+  #   let
+  #     pkgs = import inputs.nixpkgs { inherit system; };
+  #     home-manager = inputs.home-manager.defaultPackage."${system}";
+  #   in rec {
+  #     packages = pkgs // {
+  #       inherit home-manager;
+
+  #       tools = import ./tools { inherit pkgs; };
+  #       ops = import ./ops { inherit pkgs; };
+  #       users.fcuny = import ./users/fcuny { inherit pkgs; };
+  #     };
 }
diff --git a/hosts/aptos/default.nix b/hosts/aptos/default.nix
index 7c51741..f92ce07 100644
--- a/hosts/aptos/default.nix
+++ b/hosts/aptos/default.nix
@@ -1,14 +1,7 @@
 { config, pkgs, hostname, ... }:
 
 {
-  imports = [
-    # Include the results of the hardware scan.
-    ./hardware.nix
-    ./sound.nix
-    ./networking.nix
-    ./home.nix
-    ./services.nix
-  ];
+  imports = [ ./hardware.nix ./sound.nix ./networking.nix ./services.nix ];
 
   # Allow setting GTK configuration using home-manager
   programs.dconf.enable = true;
diff --git a/hosts/carmel/default.nix b/hosts/carmel/default.nix
index 00ae881..8971397 100644
--- a/hosts/carmel/default.nix
+++ b/hosts/carmel/default.nix
@@ -1,14 +1,8 @@
 { config, pkgs, hostname, ... }:
 
 {
-  imports = [
-    ./hardware.nix
-    ./boot.nix
-    ./sound.nix
-    ./networking.nix
-    ./home.nix
-    ./services.nix
-  ];
+  imports =
+    [ ./hardware.nix ./boot.nix ./sound.nix ./networking.nix ./services.nix ];
 
   # Allow setting GTK configuration using home-manager
   programs.dconf.enable = true;
diff --git a/hosts/tahoe/default.nix b/hosts/tahoe/default.nix
index ceb6152..64377b8 100644
--- a/hosts/tahoe/default.nix
+++ b/hosts/tahoe/default.nix
@@ -1,8 +1,7 @@
 { config, pkgs, hostname, ... }:
 
 {
-  imports =
-    [ ./boot.nix ./hardware.nix ./networking.nix ./home.nix ./services.nix ];
+  imports = [ ./boot.nix ./hardware.nix ./networking.nix ./services.nix ];
 
   users.groups.nas.gid = 5000;
   users.users.nas = {
diff --git a/nix/checks.nix b/nix/checks.nix
deleted file mode 100644
index aadb170..0000000
--- a/nix/checks.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ pkgs, pre-commit-hooks, ... }:
-
-with pkgs;
-
-{
-  pre-commit-check = pre-commit-hooks.lib.${system}.run {
-    src = lib.cleanSource ../.;
-    hooks = {
-      nix-linter.enable = true;
-      nixpkgs-fmt.enable = true;
-      trailing-whitespace = {
-        enable = true;
-        entry =
-          "${pkgs.python3Packages.pre-commit-hooks}/bin/trailing-whitespace-fixer";
-        types = [ "text" ];
-      };
-      end-of-file-fixer = {
-        enable = true;
-        entry =
-          "${pkgs.python3Packages.pre-commit-hooks}/bin/end-of-file-fixer";
-        types = [ "text" ];
-      };
-      terraform-format = { enable = true; };
-      shellcheck = {
-        enable = true;
-        files = "\\.sh$";
-        types_or = [ "file" ];
-      };
-    };
-  };
-}
diff --git a/nix/default.nix b/nix/default.nix
index 2dfd8a2..2e76200 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -1,5 +1,4 @@
-{ inputs }:
-
-{
+inputs: {
   mkSystem = import ./mkSystem.nix inputs;
+  mkHomeManagerConfiguration = import ./mkHomeManagerConfiguration.nix inputs;
 }
diff --git a/nix/mkHomeManagerConfiguration.nix b/nix/mkHomeManagerConfiguration.nix
new file mode 100644
index 0000000..bcf374a
--- /dev/null
+++ b/nix/mkHomeManagerConfiguration.nix
@@ -0,0 +1,28 @@
+inputs@{ self, ... }:
+{ system ? "x86_64-linux"
+, username ? "fcuny"
+, hostname
+, stateVersion ? "22.05"
+, extraModules ? [ ]
+,
+}:
+inputs.home-manager.lib.homeManagerConfiguration {
+  inherit system;
+  inherit username;
+  inherit stateVersion;
+
+  homeDirectory = "/home/${username}";
+
+  pkgs = import inputs.nixpkgs {
+    inherit system;
+    config.allowUnfree = true;
+    overlays = [
+      inputs.emacs-overlay.overlay
+      inputs.nur.overlay
+      inputs.rust.overlays.default
+      (final: prev: { tools = import "${self}/tools" { pkgs = prev; }; })
+    ];
+  };
+  configuration.imports =
+    [ "${self}/home" "${self}/hosts/${hostname}/home.nix" ];
+}
diff --git a/nix/mkSystem.nix b/nix/mkSystem.nix
index 1f7ccaf..00b5664 100644
--- a/nix/mkSystem.nix
+++ b/nix/mkSystem.nix
@@ -12,12 +12,9 @@ inputs.nixpkgs.lib.nixosSystem {
       nixpkgs = {
         config.allowUnfree = true;
         overlays = [
-          inputs.emacs-overlay.overlay
           inputs.nur.overlay
-          inputs.rust.overlay
-          (final: prev: {
-            tools = import "${self}/tools" { pkgs = prev; };
-          })
+          inputs.rust.overlays.default
+          (final: prev: { tools = import "${self}/tools" { pkgs = prev; }; })
         ];
       };
       # Add each input as a registry