From f9f39bf70d1283cd5c0700644b155661f1ebfa6b Mon Sep 17 00:00:00 2001 From: NullBite Date: Thu, 20 Feb 2025 00:28:12 -0500 Subject: [PATCH] flake: add flake-compat It is good for if I am making a nix update script that needs network access or some other impurity (although this is probably what nix-prefetch-git is for but it's good to know how to do it manually, especially for something like recreating a lockfile) --- default.nix | 13 +++++++++++++ flake.lock | 44 ++++++++++++++++++++++++++++++-------------- flake.nix | 6 ++++++ 3 files changed, 49 insertions(+), 14 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..85cb538 --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +(import + ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + nodeName = lock.nodes.root.inputs.flake-compat; + in + fetchTarball { + url = lock.nodes.${nodeName}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz"; + sha256 = lock.nodes.${nodeName}.locked.narHash; + } + ) + { src = ./.; } +).defaultNix diff --git a/flake.lock b/flake.lock index 55f13fb..cd94e7b 100644 --- a/flake.lock +++ b/flake.lock @@ -177,13 +177,12 @@ } }, "flake-compat": { - "flake": false, "locked": { - "lastModified": 1696426674, - "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "lastModified": 1733328505, + "narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=", "owner": "edolstra", "repo": "flake-compat", - "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", "type": "github" }, "original": { @@ -211,11 +210,11 @@ "flake-compat_3": { "flake": false, "locked": { - "lastModified": 1673956053, - "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", "owner": "edolstra", "repo": "flake-compat", - "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", "type": "github" }, "original": { @@ -241,6 +240,22 @@ } }, "flake-compat_5": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_6": { "flake": false, "locked": { "lastModified": 1733328505, @@ -256,7 +271,7 @@ "type": "github" } }, - "flake-compat_6": { + "flake-compat_7": { "flake": false, "locked": { "lastModified": 1733328505, @@ -983,7 +998,7 @@ "lanzaboote": { "inputs": { "crane": "crane", - "flake-compat": "flake-compat_2", + "flake-compat": "flake-compat_3", "flake-parts": "flake-parts_2", "nixpkgs": [ "nixpkgs" @@ -1028,7 +1043,7 @@ }, "nix-minecraft": { "inputs": { - "flake-compat": "flake-compat_3", + "flake-compat": "flake-compat_4", "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs-unstable" @@ -1051,7 +1066,7 @@ }, "nix-minecraft-upstream": { "inputs": { - "flake-compat": "flake-compat_4", + "flake-compat": "flake-compat_5", "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs-unstable" @@ -1073,7 +1088,7 @@ }, "nix-wsl": { "inputs": { - "flake-compat": "flake-compat_5", + "flake-compat": "flake-compat_6", "nixpkgs": [ "nixpkgs" ] @@ -1209,7 +1224,7 @@ }, "pre-commit-hooks": { "inputs": { - "flake-compat": "flake-compat", + "flake-compat": "flake-compat_2", "gitignore": "gitignore", "nixpkgs": [ "hyprland", @@ -1261,6 +1276,7 @@ "inputs": { "agenix": "agenix", "base16": "base16", + "flake-compat": "flake-compat", "flake-parts": "flake-parts", "home-manager": "home-manager_2", "home-manager-unstable": "home-manager-unstable", @@ -1332,7 +1348,7 @@ "base16-helix": "base16-helix", "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", - "flake-compat": "flake-compat_6", + "flake-compat": "flake-compat_7", "flake-utils": "flake-utils_3", "git-hooks": "git-hooks", "gnome-shell": "gnome-shell", diff --git a/flake.nix b/flake.nix index bb64e1c..550c69f 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,12 @@ flake-parts.url = "github:hercules-ci/flake-parts"; + # this is nice so one-off impure scripts can interact with attributes in + # this flake + flake-compat = { + url = "github:edolstra/flake-compat"; + }; + home-manager = { url = "github:nix-community/home-manager/release-23.11"; inputs.nixpkgs.follows = "nixpkgs";