treewide: nixfmt
This commit is contained in:
parent
4f4dec9f65
commit
4021fa3c83
6 changed files with 143 additions and 87 deletions
|
|
@ -4,9 +4,14 @@
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (system: {
|
flake-utils.lib.eachDefaultSystem (system: {
|
||||||
packages.nur = nixpkgs.legacyPackages.${system}.python3.pkgs.callPackage ./nur.nix {};
|
packages.nur = nixpkgs.legacyPackages.${system}.python3.pkgs.callPackage ./nur.nix { };
|
||||||
defaultPackage = self.packages.${system}.nur;
|
defaultPackage = self.packages.${system}.nur;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
ci/nur.nix
22
ci/nur.nix
|
|
@ -1,4 +1,11 @@
|
||||||
{ buildPythonApplication, lib, nix-prefetch-git, git, nix, glibcLocales }:
|
{
|
||||||
|
buildPythonApplication,
|
||||||
|
lib,
|
||||||
|
nix-prefetch-git,
|
||||||
|
git,
|
||||||
|
nix,
|
||||||
|
glibcLocales,
|
||||||
|
}:
|
||||||
|
|
||||||
buildPythonApplication {
|
buildPythonApplication {
|
||||||
name = "nur";
|
name = "nur";
|
||||||
|
|
@ -7,7 +14,16 @@ buildPythonApplication {
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
|
|
||||||
makeWrapperArgs = [
|
makeWrapperArgs = [
|
||||||
"--prefix" "PATH" ":" "${lib.makeBinPath [ nix-prefetch-git git nix ]}"
|
"--prefix"
|
||||||
"--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive"
|
"PATH"
|
||||||
|
":"
|
||||||
|
"${lib.makeBinPath [
|
||||||
|
nix-prefetch-git
|
||||||
|
git
|
||||||
|
nix
|
||||||
|
]}"
|
||||||
|
"--set"
|
||||||
|
"LOCALE_ARCHIVE"
|
||||||
|
"${glibcLocales}/lib/locale/locale-archive"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
40
default.nix
40
default.nix
|
|
@ -1,7 +1,8 @@
|
||||||
{ nurpkgs ? import <nixpkgs> {} # For nixpkgs dependencies used by NUR itself
|
{
|
||||||
|
nurpkgs ? import <nixpkgs> { }, # For nixpkgs dependencies used by NUR itself
|
||||||
# Dependencies to call NUR repos with
|
# Dependencies to call NUR repos with
|
||||||
, pkgs ? null
|
pkgs ? null,
|
||||||
, repoOverrides ? { }
|
repoOverrides ? { },
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
@ -10,18 +11,29 @@ let
|
||||||
|
|
||||||
inherit (nurpkgs) lib;
|
inherit (nurpkgs) lib;
|
||||||
|
|
||||||
repoSource = name: attr: import ./lib/repoSource.nix {
|
repoSource =
|
||||||
inherit name attr manifest lockedRevisions lib;
|
name: attr:
|
||||||
inherit (nurpkgs) fetchgit fetchzip;
|
import ./lib/repoSource.nix {
|
||||||
};
|
inherit
|
||||||
|
name
|
||||||
|
attr
|
||||||
|
manifest
|
||||||
|
lockedRevisions
|
||||||
|
lib
|
||||||
|
;
|
||||||
|
inherit (nurpkgs) fetchgit fetchzip;
|
||||||
|
};
|
||||||
|
|
||||||
createRepo = name: attr: import ./lib/evalRepo.nix {
|
createRepo =
|
||||||
inherit name pkgs lib;
|
name: attr:
|
||||||
inherit (attr) url;
|
import ./lib/evalRepo.nix {
|
||||||
src = repoSource name attr + ("/" + (attr.file or ""));
|
inherit name pkgs lib;
|
||||||
};
|
inherit (attr) url;
|
||||||
|
src = repoSource name attr + ("/" + (attr.file or ""));
|
||||||
|
};
|
||||||
|
|
||||||
in {
|
in
|
||||||
repos = (lib.mapAttrs createRepo manifest) // repoOverrides;
|
{
|
||||||
|
repos = (lib.mapAttrs createRepo manifest) // repoOverrides;
|
||||||
repo-sources = lib.mapAttrs repoSource manifest;
|
repo-sources = lib.mapAttrs repoSource manifest;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
44
flake.nix
44
flake.nix
|
|
@ -1,27 +1,31 @@
|
||||||
{
|
{
|
||||||
description = "Nix User Repository";
|
description = "Nix User Repository";
|
||||||
|
|
||||||
outputs = { self }: {
|
outputs =
|
||||||
overlay = final: prev: {
|
{ self }:
|
||||||
nur = import ./default.nix {
|
{
|
||||||
nurpkgs = prev;
|
overlay = final: prev: {
|
||||||
pkgs = 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;
|
|
||||||
};
|
|
||||||
description = "Use this option to import packages from NUR";
|
|
||||||
default = import self {
|
|
||||||
nurpkgs = pkgs;
|
|
||||||
pkgs = pkgs;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
nixosModules.nur =
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hmModules.nur = self.nixosModules.nur;
|
||||||
};
|
};
|
||||||
hmModules.nur = self.nixosModules.nur;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{ name
|
{
|
||||||
, url
|
name,
|
||||||
, src
|
url,
|
||||||
, pkgs # Do not use this for anything other than passing it along as an argument to the repository
|
src,
|
||||||
, lib
|
pkgs, # Do not use this for anything other than passing it along as an argument to the repository
|
||||||
|
lib,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
|
|
@ -10,24 +11,33 @@ let
|
||||||
|
|
||||||
# Arguments passed to each repositories default.nix
|
# Arguments passed to each repositories default.nix
|
||||||
passedArgs = {
|
passedArgs = {
|
||||||
pkgs = if pkgs != null then pkgs else throw ''
|
pkgs =
|
||||||
NUR import call didn't receive a pkgs argument, but the evaluation of NUR's ${prettyName} repository requires it.
|
if pkgs != null then
|
||||||
|
pkgs
|
||||||
|
else
|
||||||
|
throw ''
|
||||||
|
NUR import call didn't receive a pkgs argument, but the evaluation of NUR's ${prettyName} repository requires it.
|
||||||
|
|
||||||
This is either because
|
This is either because
|
||||||
- You're trying to use a [1mpackage[0m from that repository, but didn't pass a `pkgs` argument to the NUR import.
|
- You're trying to use a [1mpackage[0m from that repository, but didn't pass a `pkgs` argument to the NUR import.
|
||||||
In that case, refer to the installation instructions at https://github.com/nix-community/nur#installation on how to properly import NUR
|
In that case, refer to the installation instructions at https://github.com/nix-community/nur#installation on how to properly import NUR
|
||||||
|
|
||||||
- You're trying to use a [1mmodule[0m/[1moverlay[0m from that repository, but it didn't properly declare their module.
|
- You're trying to use a [1mmodule[0m/[1moverlay[0m from that repository, but it didn't properly declare their module.
|
||||||
In that case, inform the maintainer of the repository: ${url}
|
In that case, inform the maintainer of the repository: ${url}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
expr = import src;
|
expr = import src;
|
||||||
args = builtins.functionArgs expr;
|
args = builtins.functionArgs expr;
|
||||||
# True if not all arguments are either passed by default (e.g. pkgs) or defaulted (e.g. foo ? 10)
|
# True if not all arguments are either passed by default (e.g. pkgs) or defaulted (e.g. foo ? 10)
|
||||||
usesCallPackage = ! lib.all (arg: lib.elem arg (lib.attrNames passedArgs) || args.${arg}) (lib.attrNames args);
|
usesCallPackage =
|
||||||
|
!lib.all (arg: lib.elem arg (lib.attrNames passedArgs) || args.${arg}) (lib.attrNames args);
|
||||||
|
|
||||||
in if usesCallPackage then throw ''
|
in
|
||||||
|
if usesCallPackage then
|
||||||
|
throw ''
|
||||||
NUR repository ${prettyName} is using the deprecated callPackage syntax which
|
NUR repository ${prettyName} is using the deprecated callPackage syntax which
|
||||||
might result in infinite recursion when used with NixOS modules.
|
might result in infinite recursion when used with NixOS modules.
|
||||||
'' else expr (builtins.intersectAttrs args passedArgs)
|
''
|
||||||
|
else
|
||||||
|
expr (builtins.intersectAttrs args passedArgs)
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,26 @@
|
||||||
{
|
{
|
||||||
name, attr,
|
name,
|
||||||
fetchgit, fetchzip, lib,
|
attr,
|
||||||
manifest, lockedRevisions
|
fetchgit,
|
||||||
|
fetchzip,
|
||||||
|
lib,
|
||||||
|
manifest,
|
||||||
|
lockedRevisions,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
parseGitlabUrl = url: with builtins; let
|
parseGitlabUrl =
|
||||||
parts = lib.splitString "/" url;
|
url:
|
||||||
len = length parts;
|
with builtins;
|
||||||
in {
|
let
|
||||||
domain = elemAt parts 2;
|
parts = lib.splitString "/" url;
|
||||||
# Allow for deeper hierarchies than owner/repo (GL has groups and subgroups)
|
len = length parts;
|
||||||
path = lib.drop 3 parts;
|
in
|
||||||
};
|
{
|
||||||
|
domain = elemAt parts 2;
|
||||||
|
# Allow for deeper hierarchies than owner/repo (GL has groups and subgroups)
|
||||||
|
path = lib.drop 3 parts;
|
||||||
|
};
|
||||||
|
|
||||||
revision = lockedRevisions.${name};
|
revision = lockedRevisions.${name};
|
||||||
submodules = attr.submodules or false;
|
submodules = attr.submodules or false;
|
||||||
|
|
@ -20,24 +28,25 @@ let
|
||||||
|
|
||||||
localPath = ../repos + "/${name}";
|
localPath = ../repos + "/${name}";
|
||||||
in
|
in
|
||||||
if lib.pathExists localPath then
|
if lib.pathExists localPath then
|
||||||
localPath
|
localPath
|
||||||
else if lib.hasPrefix "https://github.com" attr.url && !submodules then
|
else if lib.hasPrefix "https://github.com" attr.url && !submodules then
|
||||||
fetchzip {
|
fetchzip {
|
||||||
url = "${attr.url}/archive/${revision.rev}.zip";
|
url = "${attr.url}/archive/${revision.rev}.zip";
|
||||||
inherit (revision) sha256;
|
inherit (revision) sha256;
|
||||||
}
|
}
|
||||||
else if (lib.hasPrefix "https://gitlab.com" attr.url || type == "gitlab") && !submodules then
|
else if (lib.hasPrefix "https://gitlab.com" attr.url || type == "gitlab") && !submodules then
|
||||||
let
|
let
|
||||||
gitlab = parseGitlabUrl attr.url;
|
gitlab = parseGitlabUrl attr.url;
|
||||||
escapedPath = builtins.concatStringsSep "%2F" gitlab.path;
|
escapedPath = builtins.concatStringsSep "%2F" gitlab.path;
|
||||||
in fetchzip {
|
in
|
||||||
url = "https://${gitlab.domain}/api/v4/projects/${escapedPath}/repository/archive.tar.gz?sha=${revision.rev}";
|
fetchzip {
|
||||||
inherit (revision) sha256;
|
url = "https://${gitlab.domain}/api/v4/projects/${escapedPath}/repository/archive.tar.gz?sha=${revision.rev}";
|
||||||
}
|
inherit (revision) sha256;
|
||||||
else
|
}
|
||||||
fetchgit {
|
else
|
||||||
inherit (attr) url;
|
fetchgit {
|
||||||
inherit (revision) rev sha256;
|
inherit (attr) url;
|
||||||
fetchSubmodules = submodules;
|
inherit (revision) rev sha256;
|
||||||
}
|
fetchSubmodules = submodules;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue