From a684e7f0beaccb5afe49c5aaeefeabc8e0d73543 Mon Sep 17 00:00:00 2001 From: storvik Date: Fri, 18 Oct 2024 21:59:04 +0200 Subject: [PATCH] Add support for darwin and update flake --- flake.lock | 69 +++++--------------------------------------------- flake.nix | 41 +++++++++++++++--------------- go.mod | 2 +- gomod2nix.toml | 20 +++++++-------- shell.nix | 2 +- 5 files changed, 40 insertions(+), 94 deletions(-) diff --git a/flake.lock b/flake.lock index 8918e34..ee90a2c 100644 --- a/flake.lock +++ b/flake.lock @@ -4,24 +4,6 @@ "inputs": { "systems": "systems" }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, "locked": { "lastModified": 1694529238, "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", @@ -36,39 +18,19 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "gomod2nix": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1721902146, - "narHash": "sha256-zIycVdlCezEPqbbznII1VSC+gR4W2woG8EEEwz7Zjy0=", + "lastModified": 1728509152, + "narHash": "sha256-tQo1rg3TlwgyI8eHnLvZSlQx9d/o2Rb4oF16TfaTOw0=", "owner": "tweag", "repo": "gomod2nix", - "rev": "7b8ef0d5fdc09b3a7acb27f1e6c168888947f364", + "rev": "d5547e530464c562324f171006fc8f639aa01c9f", "type": "github" }, "original": { @@ -79,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1721743106, - "narHash": "sha256-adRZhFpBTnHiK3XIELA3IBaApz70HwCYfv7xNrHjebA=", + "lastModified": 1729070438, + "narHash": "sha256-KOTTUfPkugH52avUvXGxvWy8ibKKj4genodIYUED+Kc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dc14ed91132ee3a26255d01d8fd0c1f5bff27b2f", + "rev": "5785b6bb5eaae44e627d541023034e1601455827", "type": "github" }, "original": { @@ -95,8 +57,6 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "gitignore": "gitignore", "gomod2nix": "gomod2nix", "nixpkgs": "nixpkgs" } @@ -115,21 +75,6 @@ "repo": "default", "type": "github" } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index e87ccb4..d4db7c7 100755 --- a/flake.nix +++ b/flake.nix @@ -5,13 +5,6 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; - - gitignore = { - url = "github:hercules-ci/gitignore.nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - gomod2nix = { url = "github:tweag/gomod2nix"; inputs.nixpkgs.follows = "nixpkgs"; @@ -19,21 +12,27 @@ }; - outputs = inputs@{ self, nixpkgs, flake-utils, gitignore, gomod2nix }: + outputs = inputs@{ self, nixpkgs, gomod2nix }: let - pkgs = import nixpkgs { - system = "x86_64-linux"; - overlays = [ - gomod2nix.overlays.default - self.overlays.default - ]; - }; + linuxSystems = [ "x86_64-linux" "aarch64-linux" ]; + darwinSystems = [ "aarch64-darwin" "x86_64-darwin" ]; + forAllSystems = function: + nixpkgs.lib.genAttrs (linuxSystems ++ darwinSystems) + (system: + function (import nixpkgs { + inherit system; + overlays = [ + gomod2nix.overlays.default + ]; + config = { }; + })); version = "0.3.0"; - inherit (gitignore.lib) gitignoreSource; in { - overlays.default = import ./nix/overlay.nix { inherit pkgs; }; + overlays = forAllSystems (pkgs: { + default = import ./nix/overlay.nix { inherit pkgs; }; + }); nixosModules.goshrt = import ./nix/module.nix self; @@ -46,12 +45,14 @@ ]; }; - packages."x86_64-linux" = { + packages = forAllSystems (pkgs: { goshrt = pkgs.callPackage ./nix/goshrt.nix { inherit version; }; goshrtc = pkgs.callPackage ./nix/goshrtc.nix { inherit version; }; default = pkgs.callPackage ./nix/goshrt.nix { inherit version; }; - }; + }); - devShells."x86_64-linux".default = import ./shell.nix { inherit pkgs; }; + devShells = forAllSystems (pkgs: { + default = import ./shell.nix { inherit pkgs; }; + }); }; } diff --git a/go.mod b/go.mod index 72142c2..b5ed9fc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/storvik/goshrt -go 1.21 +go 1.23.2 require ( github.com/adrg/xdg v0.5.1 diff --git a/gomod2nix.toml b/gomod2nix.toml index ef19b65..a7e559c 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -2,11 +2,11 @@ schema = 3 [mod] [mod."github.com/adrg/xdg"] - version = "v0.5.0" - hash = "sha256-hYxtRzeFzT+4zbslWSZWmUJf+OBDmCiwL0D/0Ry8Z2I=" + version = "v0.5.1" + hash = "sha256-Jjl0HQX+BXtQgPe4vAeyfhakjn3zxPWI8IdwXP5dJ9s=" [mod."github.com/cpuguy83/go-md2man/v2"] - version = "v2.0.4" - hash = "sha256-pQ+H8Psh92KWTang8hK0cHFLomH+4X0rMMilIJUQ4Qc=" + version = "v2.0.5" + hash = "sha256-UX9FajFqZApVFED3MYcq167iPwztnIck25ehfcOeFD8=" [mod."github.com/go-chi/chi/v5"] version = "v5.1.0" hash = "sha256-DpVfbPlJe4zQNdBrirWq9Q37/awSu5zb3IJgcuyEED8=" @@ -23,11 +23,11 @@ schema = 3 version = "v2.1.0" hash = "sha256-R+84l1si8az5yDqd5CYcFrTyNZ1eSYlpXKq6nFt4OTQ=" [mod."github.com/urfave/cli/v2"] - version = "v2.27.2" - hash = "sha256-P0yLmx2a2hIQjQ/RXKLG8ehI5eVivnettuMFr8MznFY=" + version = "v2.27.5" + hash = "sha256-b/mERhhQ7CHxVEyf2QXfVnZut9pgMMVgL4zs2Wh9s4A=" [mod."github.com/xrash/smetrics"] - version = "v0.0.0-20240312152122-5f08fbb34913" - hash = "sha256-ySUTdeoOUi3QcLEJBYvCDIhVrsrD2Ks6/4V9n4hCvBk=" + version = "v0.0.0-20240521201337-686a1a2994c1" + hash = "sha256-CsyN59w6sKERDI5kkdpq0YKmqdixyCHuN4FYE/56/BQ=" [mod."golang.org/x/sys"] - version = "v0.22.0" - hash = "sha256-RbG0XaXGGlErCsl2agvUxMnrkRwdbJLmriYT1H24FwA=" + version = "v0.26.0" + hash = "sha256-YjklsWNhx4g4TaWRWfFe1TMFKujbqiaNvZ38bfI35fM=" diff --git a/shell.nix b/shell.nix index 22a4f12..805c379 100644 --- a/shell.nix +++ b/shell.nix @@ -5,7 +5,7 @@ pkgs.mkShell buildInputs = [ # disabled as it does not pickup go version from go.mod # (pkgs.mkGoEnv { pwd = ./.; }) - pkgs.go_1_21 + pkgs.go pkgs.gomod2nix pkgs.govulncheck pkgs.golangci-lint