From f4ecea2443e7905f01d06b9a00c3219c0c7799ff Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Fri, 23 Aug 2024 12:40:23 -0400 Subject: [PATCH] flake: temporarily use nix-update git --- flake.lock | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 15 +++++++++++-- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index 1fd089cd..3a3d4360 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,49 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nix-update", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nix-update": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1724271552, + "narHash": "sha256-xn0dC4M3mfItxP+s3/v3Hz/CSKp74VH/gMfufKxl9/4=", + "owner": "Mic92", + "repo": "nix-update", + "rev": "737121eccb67542e8c004c64da833fede2e80c64", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "nix-update", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1724224976, @@ -51,6 +94,7 @@ "root": { "inputs": { "flake-compat": "flake-compat", + "nix-update": "nix-update", "nixpkgs": "nixpkgs", "nixpkgs-stable": "nixpkgs-stable", "rust-overlay": "rust-overlay" @@ -75,6 +119,27 @@ "repo": "rust-overlay", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nix-update", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719887753, + "narHash": "sha256-p0B2r98UtZzRDM5miGRafL4h7TwGRC4DII+XXHDHqek=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "bdb6355009562d8f9313d9460c0d3860f525bc6c", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index d0d4e596..7b5d1b04 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,12 @@ url = "github:nix-community/flake-compat"; flake = false; }; + + # TODO: remove when nix-update is bumped in nixpkgs with a release containing + nix-update = { + url = "github:Mic92/nix-update"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { self, nixpkgs, nixpkgs-stable, rust-overlay, ... }: let @@ -44,14 +50,19 @@ default = import ./nixos { cosmicOverlay = self.overlays.default; }; }; - legacyPackages = forAllSystems (system: let lib = nixpkgs.lib; pkgs = nixpkgs.legacyPackages.${system}; in { + legacyPackages = forAllSystems (system: let + lib = nixpkgs.lib; + # TODO: revert when nix-update is bumped in nixpkgs with a release containing + #pkgs = nixpkgs.legacyPackages.${system}; + pkgs = nixpkgs.legacyPackages.${system}.extend (final: prev: { nix-update = self.inputs.nix-update.packages.${system}.default; }); + in { update = pkgs.writeShellApplication { name = "cosmic-unstable-update"; text = lib.concatStringsSep "\n" (lib.mapAttrsToList (attr: drv: if drv ? updateScript && (lib.isList drv.updateScript) && (lib.length drv.updateScript) > 0 then lib.escapeShellArgs (drv.updateScript ++ lib.optionals (lib.match "nix-update|.*/nix-update" (lib.head drv.updateScript) != null) [ "--version" "branch=HEAD" "--commit" attr ]) - else builtins.toString drv.updateScript or "") self.packages.${system}); + else builtins.toString drv.updateScript or "") (self.lib.packagesFor pkgs)); }; vm = nixpkgs.lib.makeOverridable ({ nixpkgs }: let