From 0099f8e8de0b6a735015942d0215ebfed8c50a5a Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 15 Jan 2024 10:27:16 +0100 Subject: [PATCH] Add best-effort flake.nix The purpose for this flake is to make `nix run nix/2.3-maintenance` work, so that it's easier to answer questions about this old series of releases. --- flake.lock | 27 ++++++++++++++++++++++++++ flake.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..588ac8d77 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1705133751, + "narHash": "sha256-rCIsyE80jgiOU78gCWN3A0wE0tR2GI5nH6MlS+HaaSQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b19f5e77dd906cb52dade0b7bd280339d2a1f3d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..771f66501 --- /dev/null +++ b/flake.nix @@ -0,0 +1,56 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + # A very basic flake to conveniently `nix run nix/2.3` for testing. + # Note that this release has no built-in support for flakes, + # and this flake declaration is provided on a best-effort basis. + outputs = { self, nixpkgs, ... }: + let + inherit (nixpkgs) lib; + inherit (lib) flip genAttrs mapAttrs substring; + rev = self.sourceInfo.rev or self.sourceInfo.dirtyRev or ""; + revCount = self.sourceInfo.revCount or 0; + shortRev = self.sourceInfo.shortRev or (substring 0 7 rev); + release = import ./release.nix { + nix = { + outPath = ./.; + inherit rev revCount shortRev; + }; + nixpkgs = nixpkgs.outPath; + officialRelease = false; + }; + in + { + # inherit release; + packages = + mapAttrs + (system: nix: { + default = nix; + nix = nix; + }) + release.build; + apps = + mapAttrs + (system: packages: + let + appFor = mainProgram: { + type = "app"; + program = lib.getExe' packages.nix mainProgram; + }; + in flip genAttrs appFor [ + "nix" + "nix-build" + "nix-channel" + "nix-collect-garbage" + "nix-copy-closure" + "nix-daemon" + "nix-env" + "nix-hash" + "nix-instantiate" + "nix-prefetch-url" + "nix-shell" + "nix-store" + ]) + self.packages; + }; +} +