Skip to content

Commit

Permalink
flakeify NUR
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Dec 5, 2024
1 parent 7526d8d commit 13b61c1
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 18 deletions.
2 changes: 2 additions & 0 deletions ci/update-nur.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ git clone \

nix run "${DIR}#" -- combine nur-combined

nix flake lock --update-input nixpkgs

if [[ -z "$(git diff --exit-code)" ]]; then
echo "No changes to the output on this push; exiting."
else
Expand Down
64 changes: 63 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 35 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
{
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
overlay = final: prev: {
nur = import ./default.nix {
nurpkgs = prev;
pkgs = prev;
};
};
nixosModules.nur =
{ lib, pkgs, ... }:
in
flake-parts.lib.mkFlake { inherit inputs; } {
systems = builtins.filter (
system: builtins.hasAttr system nixpkgs.legacyPackages
) nixpkgs.lib.platforms.all;
flake = {
overlays.default = overlay;
};
imports = [
inputs.treefmt-nix.flakeModule
];
perSystem =
{ system, ... }:
{
options.nur = lib.mkOption {
type = lib.mkOptionType {
name = "nur";
description = "An instance of the Nix User repository";
check = builtins.isAttrs;
};
description = "Use this option to import packages from NUR";
default = import self {
nurpkgs = pkgs;
pkgs = 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 =
(import nixpkgs {
inherit system;
overlays = [ overlay ];
}).nur;
};
hmModules.nur = self.nixosModules.nur;
};
}

0 comments on commit 13b61c1

Please sign in to comment.