flakeify NUR

This commit is contained in:
Gavin John 2024-12-05 12:17:16 -08:00 committed by mergify[bot]
parent 42a0caa391
commit ecb7137813
3 changed files with 115 additions and 16 deletions

View file

@ -19,6 +19,8 @@ git clone \
nix run "${DIR}#" -- combine nur-combined
nix flake update nixpkgs
if [[ -z "$(git diff --exit-code)" ]]; then
echo "No changes to the output on this push; exiting."
else

64
flake.lock generated
View file

@ -1,6 +1,68 @@
{
"nodes": {
"root": {}
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1733312601,
"narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733212471,
"narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "55d15ad12a74eb7d4646254e13638ad0c4128776",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"nixpkgs": "nixpkgs",
"treefmt-nix": "treefmt-nix"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1733222881,
"narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "49717b5af6f80172275d47a418c9719a31a78b53",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
}
},
"root": "root",
"version": 7

View file

@ -1,31 +1,66 @@
{
description = "Nix User Repository";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self }:
{
inputs@{ flake-parts, nixpkgs, ... }:
let
inherit (nixpkgs) lib;
manifest = (builtins.fromJSON (builtins.readFile ./repos.json)).repos;
overlay = final: prev: {
nur = import ./default.nix {
nurpkgs = prev;
pkgs = prev;
};
};
nixosModules.nur =
{ lib, pkgs, ... }:
{
options.nur = lib.mkOption {
type = lib.mkOptionType {
name = "nur";
description = "An instance of the Nix User repository";
check = builtins.isAttrs;
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = builtins.filter (
system: builtins.hasAttr system nixpkgs.legacyPackages
) nixpkgs.lib.platforms.all;
flake = {
overlay = lib.warn "nur.overlay has been replaced by nur.overlays.default" overlay; # Added 2024-12-06
nixosModules.nur = lib.throw "nur.nixosModules.nur has been replaced by nur.modules.nixos.default"; # Added 2024-12-06
hmModules.nur = lib.throw "nur.hmModules.nur has been replaced by nur.modules.home-manager.default"; # Added 2024-12-06
overlays = {
default = overlay;
};
modules = {
nixos = {
default = {
nixpkgs.overlays = [ overlay ];
};
description = "Use this option to import packages from NUR";
default = import self {
nurpkgs = pkgs;
pkgs = pkgs;
};
home-manager = {
default = {
nixpkgs.overlays = [ overlay ];
};
};
};
hmModules.nur = self.nixosModules.nur;
};
imports = [
inputs.flake-parts.flakeModules.modules
inputs.treefmt-nix.flakeModule
];
perSystem =
{ pkgs, ... }:
{
treefmt.programs.nixfmt.enable = true;
# legacyPackages is used because nur is a package set
# This trick with the overlay is used because it allows NUR packages to depend on other NUR packages
legacyPackages = (pkgs.extend overlay).nur;
};
};
}