summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorseth <[email protected]>2023-03-09 19:39:23 -0500
committerseth <[email protected]>2023-03-09 19:39:38 -0500
commit721a349afd94a6f58d29d07185024d174a782201 (patch)
tree8ae2d14d8458e8598a80fe35d2fe1b90ce811f88
parentbc6276ede166783c5ba2aa1be504e3bbb546343e (diff)
add checks and dev shell
-rw-r--r--.envrc1
-rw-r--r--.github/workflows/check.yml26
-rw-r--r--.gitignore5
-rw-r--r--flake.lock95
-rw-r--r--flake.nix35
-rw-r--r--hosts/glados/hardware-configuration.nix1
6 files changed, 159 insertions, 4 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..3550a30
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
new file mode 100644
index 0000000..f35e930
--- /dev/null
+++ b/.github/workflows/check.yml
@@ -0,0 +1,26 @@
+name: check flake
+
+on:
+ pull_request:
+ paths:
+ - "**.nix"
+ push:
+ paths:
+ - "**.nix"
+ workflow_dispatch:
+
+jobs:
+ check:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: cachix/install-nix-action@v19
+ with:
+ github_access_token: ${{ secrets.GITHUB_TOKEN }}
+
+ - run: |
+ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1
+ export NIXPKGS_ALLOW_BROKEN=1
+ export NIXPKGS_ALLOW_UNFREE=1
+ nix flake check --impure
diff --git a/.gitignore b/.gitignore
index b2be92b..a71e2bf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,6 @@
+# build artifacts
result
+
+# dev shell
+.pre-commit-config.yaml
+.direnv/
diff --git a/flake.lock b/flake.lock
index 7542380..28e72d4 100644
--- a/flake.lock
+++ b/flake.lock
@@ -94,6 +94,22 @@
"type": "github"
}
},
+ "flake-compat_5": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1673956053,
+ "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
@@ -142,6 +158,21 @@
"type": "github"
}
},
+ "flake-utils_3": {
+ "locked": {
+ "lastModified": 1667395993,
+ "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
"getchoo": {
"inputs": {
"naersk": "naersk",
@@ -186,6 +217,27 @@
"type": "github"
}
},
+ "gitignore_2": {
+ "inputs": {
+ "nixpkgs": [
+ "pre-commit-hooks",
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1660459072,
+ "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
"home-manager": {
"inputs": {
"nixpkgs": [
@@ -341,6 +393,22 @@
"type": "github"
}
},
+ "nixpkgs-stable_2": {
+ "locked": {
+ "lastModified": 1673800717,
+ "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-22.11",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
"nixpkgs-test": {
"locked": {
"lastModified": 1671812130,
@@ -387,6 +455,30 @@
"type": "github"
}
},
+ "pre-commit-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat_5",
+ "flake-utils": "flake-utils_3",
+ "gitignore": "gitignore_2",
+ "nixpkgs": [
+ "nixpkgs"
+ ],
+ "nixpkgs-stable": "nixpkgs-stable_2"
+ },
+ "locked": {
+ "lastModified": 1678376203,
+ "narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=",
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "rev": "1a20b9708962096ec2481eeb2ddca29ed747770a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "pre-commit-hooks.nix",
+ "type": "github"
+ }
+ },
"pre-commit-hooks-nix": {
"inputs": {
"flake-compat": "flake-compat_3",
@@ -424,7 +516,8 @@
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs",
"nixpkgsUnstable": "nixpkgsUnstable",
- "nur": "nur"
+ "nur": "nur",
+ "pre-commit-hooks": "pre-commit-hooks"
}
},
"rust-overlay": {
diff --git a/flake.nix b/flake.nix
index 98bb672..c694a0a 100644
--- a/flake.nix
+++ b/flake.nix
@@ -19,11 +19,17 @@
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
nur.url = "github:nix-community/NUR";
+ pre-commit-hooks = {
+ url = "github:cachix/pre-commit-hooks.nix";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
};
outputs = inputs @ {
+ self,
nixpkgs,
nixpkgsUnstable,
+ pre-commit-hooks,
...
}: let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
@@ -45,10 +51,35 @@
users = import ./users {inherit inputs;};
hosts = import ./hosts {inherit inputs;};
in {
- homeConfigurations = forAllSystems (system: mapHMUsers (users.users {inherit system;}));
+ checks = forAllSystems (system: {
+ pre-commit-check = pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ alejandra.enable = true;
+ deadnix.enable = true;
+ statix.enable = true;
+ };
+ };
+ });
- nixosConfigurations = mapHosts hosts;
+ devShells = forAllSystems (system: let
+ pkgs = nixpkgs.legacyPackages.${system};
+ in
+ with pkgs; {
+ default = mkShell {
+ inherit (self.checks.${system}.pre-commit-check) shellHook;
+ packages = [
+ alejandra
+ deadnix
+ statix
+ ];
+ };
+ });
formatter = forAllSystems (system: channels.nixpkgs.${system}.alejandra);
+
+ homeConfigurations = forAllSystems (system: mapHMUsers (users.users {inherit system;}));
+
+ nixosConfigurations = mapHosts hosts;
};
}
diff --git a/hosts/glados/hardware-configuration.nix b/hosts/glados/hardware-configuration.nix
index 74f9d71..ba90d41 100644
--- a/hosts/glados/hardware-configuration.nix
+++ b/hosts/glados/hardware-configuration.nix
@@ -4,7 +4,6 @@
{
config,
lib,
- pkgs,
modulesPath,
...
}: {