mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 22:57:55 +00:00
bahaghari: use npins for pinning nixpkgs branches
This makes it possible for easier way to contribute with non-flakes usage.
This commit is contained in:
parent
0c69a64ff8
commit
e74640cf16
@ -2,15 +2,16 @@
|
||||
description = "Specialized set of Nix modules for generating and applying themes.";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, ... }:
|
||||
let systems = inputs.flake-utils.lib.defaultSystems;
|
||||
outputs = inputs@{ self, ... }:
|
||||
let
|
||||
systems = inputs.flake-utils.lib.defaultSystems;
|
||||
sources = import ./npins;
|
||||
in inputs.flake-utils.lib.eachSystem systems
|
||||
(system: {
|
||||
devShells.default =
|
||||
import ./shell.nix { pkgs = import nixpkgs { inherit system; }; };
|
||||
import ./shell.nix { pkgs = import sources.nixos-stable { inherit system; }; };
|
||||
}) // import ./default.nix { };
|
||||
}
|
||||
|
80
subprojects/bahaghari/npins/default.nix
Normal file
80
subprojects/bahaghari/npins/default.nix
Normal file
@ -0,0 +1,80 @@
|
||||
# Generated by npins. Do not modify; will be overwritten regularly
|
||||
let
|
||||
data = builtins.fromJSON (builtins.readFile ./sources.json);
|
||||
version = data.version;
|
||||
|
||||
mkSource =
|
||||
spec:
|
||||
assert spec ? type;
|
||||
let
|
||||
path =
|
||||
if spec.type == "Git" then
|
||||
mkGitSource spec
|
||||
else if spec.type == "GitRelease" then
|
||||
mkGitSource spec
|
||||
else if spec.type == "PyPi" then
|
||||
mkPyPiSource spec
|
||||
else if spec.type == "Channel" then
|
||||
mkChannelSource spec
|
||||
else
|
||||
builtins.throw "Unknown source type ${spec.type}";
|
||||
in
|
||||
spec // { outPath = path; };
|
||||
|
||||
mkGitSource =
|
||||
{
|
||||
repository,
|
||||
revision,
|
||||
url ? null,
|
||||
hash,
|
||||
branch ? null,
|
||||
...
|
||||
}:
|
||||
assert repository ? type;
|
||||
# At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository
|
||||
# In the latter case, there we will always be an url to the tarball
|
||||
if url != null then
|
||||
(builtins.fetchTarball {
|
||||
inherit url;
|
||||
sha256 = hash; # FIXME: check nix version & use SRI hashes
|
||||
})
|
||||
else
|
||||
assert repository.type == "Git";
|
||||
let
|
||||
urlToName =
|
||||
url: rev:
|
||||
let
|
||||
matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url;
|
||||
|
||||
short = builtins.substring 0 7 rev;
|
||||
|
||||
appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else "";
|
||||
in
|
||||
"${if matched == null then "source" else builtins.head matched}${appendShort}";
|
||||
name = urlToName repository.url revision;
|
||||
in
|
||||
builtins.fetchGit {
|
||||
url = repository.url;
|
||||
rev = revision;
|
||||
inherit name;
|
||||
# hash = hash;
|
||||
};
|
||||
|
||||
mkPyPiSource =
|
||||
{ url, hash, ... }:
|
||||
builtins.fetchurl {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
};
|
||||
|
||||
mkChannelSource =
|
||||
{ url, hash, ... }:
|
||||
builtins.fetchTarball {
|
||||
inherit url;
|
||||
sha256 = hash;
|
||||
};
|
||||
in
|
||||
if version == 3 then
|
||||
builtins.mapAttrs (_: mkSource) data.pins
|
||||
else
|
||||
throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`"
|
29
subprojects/bahaghari/npins/sources.json
Normal file
29
subprojects/bahaghari/npins/sources.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"pins": {
|
||||
"nixos-stable": {
|
||||
"type": "Git",
|
||||
"repository": {
|
||||
"type": "GitHub",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs"
|
||||
},
|
||||
"branch": "nixos-24.05",
|
||||
"revision": "b3b2b28c1daa04fe2ae47c21bb76fd226eac4ca1",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/b3b2b28c1daa04fe2ae47c21bb76fd226eac4ca1.tar.gz",
|
||||
"hash": "06jxcg73ymibvfg3czmq856f84bkhxhqgwa51mf87xprjz74zxks"
|
||||
},
|
||||
"nixos-unstable": {
|
||||
"type": "Git",
|
||||
"repository": {
|
||||
"type": "GitHub",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs"
|
||||
},
|
||||
"branch": "nixos-unstable",
|
||||
"revision": "57610d2f8f0937f39dbd72251e9614b1561942d8",
|
||||
"url": "https://github.com/NixOS/nixpkgs/archive/57610d2f8f0937f39dbd72251e9614b1561942d8.tar.gz",
|
||||
"hash": "0k8az8vmfdk1n8xlza252sqk0hm1hfc7g67adin6jxqaab2s34n9"
|
||||
}
|
||||
},
|
||||
"version": 3
|
||||
}
|
@ -1,7 +1,19 @@
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
let
|
||||
sources = import ./npins;
|
||||
in
|
||||
{ pkgs ? import sources.nixos-stable { } }:
|
||||
|
||||
with pkgs;
|
||||
|
||||
mkShell {
|
||||
inputsFrom = [ nix ];
|
||||
inputsFrom = [
|
||||
nix
|
||||
];
|
||||
|
||||
packages = [
|
||||
npins
|
||||
|
||||
treefmt
|
||||
nixpkgs-fmt
|
||||
];
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
# This is the unit cases for our Nix project.
|
||||
{ pkgs ? import <nixpkgs> { } }:
|
||||
|
||||
{ branch ? "nixos-stable" }:
|
||||
|
||||
let
|
||||
sources = import ../npins;
|
||||
pkgs = import sources.${branch} { };
|
||||
in
|
||||
{
|
||||
lib = import ./lib { inherit pkgs; };
|
||||
#modules = import ./modules { inherit pkgs; };
|
||||
|
Loading…
Reference in New Issue
Block a user