about summary refs log tree commit diff stats
path: root/flake.nix
diff options
context:
space:
mode:
authorAlan Pearce2024-05-12 22:34:23 +0200
committerAlan Pearce2024-05-12 23:12:39 +0200
commit895a3b061bb4717955ffbceab3bf3c6ecebacd70 (patch)
treefed970785b9b0460693d07dcffae08283be90ce4 /flake.nix
parent7077a3748fa545e8dee83d4f3464c55b4b459183 (diff)
downloadsearchix-895a3b061bb4717955ffbceab3bf3c6ecebacd70.tar.lz
searchix-895a3b061bb4717955ffbceab3bf3c6ecebacd70.tar.zst
searchix-895a3b061bb4717955ffbceab3bf3c6ecebacd70.zip
build: switch to flakes
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..389c646
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,62 @@
+{
+  description = "A basic gomod2nix flake";
+
+  inputs = {
+    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+    flake-utils.url = "github:numtide/flake-utils";
+    pre-commit-hooks = {
+      url = "github:cachix/pre-commit-hooks.nix";
+      inputs.flake-utils.follows = "flake-utils";
+    };
+    gomod2nix = {
+      url = "github:nix-community/gomod2nix";
+      inputs = {
+        nixpkgs.follows = "nixpkgs";
+        flake-utils.follows = "flake-utils";
+      };
+    };
+    simple-css = {
+      url = "https://raw.githubusercontent.com/kevquirk/simple.css/v2.3.0/simple.css";
+      flake = false;
+    };
+  };
+
+  outputs = { self, nixpkgs, flake-utils, gomod2nix, pre-commit-hooks, simple-css }:
+    (flake-utils.lib.eachDefaultSystem
+      (system:
+        let
+          pkgs = import nixpkgs {
+            inherit system;
+            overlays = [
+              (import ./nix/overlays)
+              gomod2nix.overlays.default
+            ];
+          };
+
+          # The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
+          # This has no effect on other platforms.
+          callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
+        in
+        {
+          packages.default = callPackage ./nix/package.nix {
+            inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
+            css = simple-css;
+          };
+          devShells.default = callPackage ./nix/dev-shell.nix {
+            pre-commit-check = {
+              inherit (self.checks.${system}.pre-commit-check)
+                shellHook
+                enabledPackages;
+            };
+            inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
+          };
+          checks = {
+            pre-commit-check = pre-commit-hooks.lib.${system}.run (
+              import ./nix/pre-commit-checks.nix {
+                inherit pkgs;
+              }
+            );
+          };
+        })
+    );
+}