From 0d047d3e46472d0bab64144cbc03d66a320566a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 17 Jun 2024 18:21:09 +0200 Subject: [PATCH] update-local-flakes: Make available as package If extensions have their lock file updated in some cases, running .#updateLocalFlakes will not work. --- common/update-local-flakes/default.nix | 2 ++ common/update-local-flakes/overlay.nix | 3 +++ .../{ => update-local-flakes}/update-local-flakes.py | 0 flake.nix | 11 ++++++++--- hm/rebuild/default.nix | 8 ++++---- 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 common/update-local-flakes/default.nix create mode 100644 common/update-local-flakes/overlay.nix rename common/{ => update-local-flakes}/update-local-flakes.py (100%) diff --git a/common/update-local-flakes/default.nix b/common/update-local-flakes/default.nix new file mode 100644 index 0000000..42ae4d8 --- /dev/null +++ b/common/update-local-flakes/default.nix @@ -0,0 +1,2 @@ +{ pkgs, ... }: +pkgs.writers.writePython3Bin "update-local-flakes" {} (builtins.readFile ./update-local-flakes.py) diff --git a/common/update-local-flakes/overlay.nix b/common/update-local-flakes/overlay.nix new file mode 100644 index 0000000..0c9b545 --- /dev/null +++ b/common/update-local-flakes/overlay.nix @@ -0,0 +1,3 @@ +(self: super: { + update-local-flakes = super.callPackage ./. {}; +}) diff --git a/common/update-local-flakes.py b/common/update-local-flakes/update-local-flakes.py similarity index 100% rename from common/update-local-flakes.py rename to common/update-local-flakes/update-local-flakes.py diff --git a/flake.nix b/flake.nix index 112b99b..2dfdffb 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,9 @@ config = { allowUnfree = true; }; + overlays = [ + (import ./common/update-local-flakes/overlay.nix) + ]; }; homeManagerConfig = { sharedModules = [ self.homeManagerModules.dotfiles ]; @@ -72,7 +75,9 @@ }; flakeTools = { self }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs (nixpkgsConfig // { + inherit system; + }); in { apps = { @@ -94,10 +99,10 @@ ${pkgs.lix}/bin/nix repl --expr 'let flake = builtins.getFlake "${self}"; in flake // flake.nixosConfigurations // rec { pkgs = import ${nixpkgs} {}; lib = pkgs.lib; }' ''}"; }; + # Available globally should this be needed in times of shenanigans updateLocalFlakes = { type = "app"; - program = "${pkgs.writers.writePython3 "update-local-flakes" { } - (builtins.readFile ./common/update-local-flakes.py)}"; + program = "${pkgs.update-local-flakes}/bin/update-local-flakes"; }; nixosRebuild = { type = "app"; diff --git a/hm/rebuild/default.nix b/hm/rebuild/default.nix index c5b8135..6100e01 100644 --- a/hm/rebuild/default.nix +++ b/hm/rebuild/default.nix @@ -1,6 +1,7 @@ { pkgs, config, ... }: { home.packages = [ + pkgs.update-local-flakes (pkgs.writeShellApplication { name = "rb"; text = '' @@ -13,21 +14,20 @@ nixos_flake="$(readlink -f /etc/nixos)" if [ -f "$nixos_flake/flake.nix" ] then - # TODO For extensions this only works on systems where the flake has been resolved - nix run "$nixos_flake#updateLocalFlakes" -- "$nixos_flake" + update-local-flakes "$nixos_flake" nix run "$nixos_flake#nixosRebuild" -- "$verb" "$@" fi # TODO Fix nix-on-droid and home-manager # hm_flake="${config.xdg.configHome}/home-manager/flake.nix" # if [ -f "$hm_flake" ] # then - # {ulf} "$hm_flake" + # update-local-flakes "$hm_flake" # home-manager "$verb" "$@" # fi # nod_flake="${config.xdg.configHome}/nix-on-droid/flake.nix" # if [ -f "$nod_flake" ] # then - # {ulf} "$nod_flake" + # update-local-flakes "$nod_flake" # nix-on-droid "$verb" --flake "$(dirname "$nod_flake")" "$@" # fi '';