From 734979e2fc445bf4c9f9c3b733c7e8d12ce79141 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Tue, 17 Sep 2024 19:11:45 -0400 Subject: [PATCH] Don't use flake-parts here It only provides a very minor benefit and can easily be replaced with a manual approach. That should address https://github.com/hercules-ci/flake-parts/issues/252. --- flake.lock | 65 +--------------------------------------- flake.nix | 87 +++++++++++++++++++++++++++++------------------------- 2 files changed, 47 insertions(+), 105 deletions(-) diff --git a/flake.lock b/flake.lock index fdfa145..c7aa94a 100644 --- a/flake.lock +++ b/flake.lock @@ -16,44 +16,10 @@ "type": "github" } }, - "flake-parts": { - "inputs": { - "nixpkgs-lib": "nixpkgs-lib" - }, - "locked": { - "lastModified": 1725234343, - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", - "path": "/nix/store/8ql43f4sxqh1dbpqy2q5jz11zdwf9832-source", - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", - "type": "path" - }, - "original": { - "id": "flake-parts", - "type": "indirect" - } - }, "flake-utils": { "inputs": { "systems": "systems" }, - "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, "locked": { "lastModified": 1710146030, "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", @@ -84,18 +50,6 @@ "type": "github" } }, - "nixpkgs-lib": { - "locked": { - "lastModified": 1725233747, - "narHash": "sha256-Ss8QWLXdr2JCBPcYChJhz4xJm+h/xjl4G0c0XlP6a74=", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/356624c12086a18f2ea2825fed34523d60ccc4e3.tar.gz" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1724748588, @@ -114,8 +68,6 @@ }, "root": { "inputs": { - "flake-parts": "flake-parts", - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "tailscale": "tailscale" } @@ -135,25 +87,10 @@ "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" - } - }, "tailscale": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs_2" }, "locked": { diff --git a/flake.nix b/flake.nix index aec20bc..3345a42 100644 --- a/flake.nix +++ b/flake.nix @@ -2,51 +2,56 @@ description = "Regenerate go module vendorHashes from inputs."; inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.tailscale.url = "github:tailscale/tailscale"; - outputs = inputs @ {flake-parts, ...}: - flake-parts.lib.mkFlake {inherit inputs;} ({ - withSystem, - flake-parts-lib, - ... - }: let - inherit (flake-parts-lib) importApply; - in { - systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"]; - - perSystem = { - config, - self', - inputs', - pkgs, - ... - }: { - formatter = pkgs.alejandra; + outputs = { + self, + nixpkgs, + tailscale, + }: let + systems = [ + "aarch64-darwin" + "aarch64-linux" + "riscv64-linux" + "x86_64-darwin" + "x86_64-linux" + ]; + eachSystem = f: + nixpkgs.lib.genAttrs systems ( + system: + f rec { + inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + devshell = import ./. {nixpkgs = pkgs;}; + } + ); + in { + formatter = eachSystem ({pkgs, ...}: pkgs.alejandra); - packages = { - default = config.packages.nardump; - nardump = pkgs.buildGo123Module rec { - pname = "nardump"; - version = inputs.tailscale.rev; - src = "${inputs.tailscale}/cmd/nardump"; - vendorHash = null; + packages = eachSystem ({ + system, + pkgs, + ... + }: { + default = self.packages.${system}.nardump; + nardump = pkgs.buildGo123Module rec { + pname = "nardump"; + version = tailscale.rev; + src = "${tailscale}/cmd/nardump"; + vendorHash = null; - # Fake up a go module inside the nardump dir, so we don't - # have to download & cache the entirety of tailscale's - # deps: - prePatch = '' - cat >go.mod <go.mod <