about summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--flake.nix149
1 files changed, 107 insertions, 42 deletions
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; };
+  #     };
 }