Skip to content

Commit

Permalink
flakeify NUR
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandapip1 committed Dec 6, 2024
1 parent 346507f commit 04ce480
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 16 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 update 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.

65 changes: 50 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;
};
};
}

0 comments on commit 04ce480

Please sign in to comment.