Pin nixpkgs and add CI
This commit is contained in:
parent
bcc385e399
commit
d45b6e7369
5 changed files with 107 additions and 1 deletions
2
ci.nix
2
ci.nix
|
|
@ -1 +1 @@
|
|||
import ./tests/default.nix
|
||||
import ./tests/default.nix { pkgs = import ./nix {}; }
|
||||
|
|
|
|||
9
nix/default.nix
Normal file
9
nix/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{ sources ? import ./sources.nix }:
|
||||
let
|
||||
config = {};
|
||||
overlays = [(super: self: {
|
||||
inherit (import sources.niv {}) niv;
|
||||
})];
|
||||
pkgs = import sources.nixpkgs { inherit overlays config; };
|
||||
in
|
||||
pkgs
|
||||
25
nix/sources.json
Normal file
25
nix/sources.json
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"nixpkgs": {
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/312a059bef8b29b4db4e73dc02ff441cab7bb26d.tar.gz",
|
||||
"owner": "NixOS",
|
||||
"branch": "nixos-19.03",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
|
||||
"repo": "nixpkgs-channels",
|
||||
"type": "tarball",
|
||||
"sha256": "1j52yvkhw1inp6ilpqy81xv1bbwgwqjn0v9647whampkqgn6dxhk",
|
||||
"description": "Nixpkgs/NixOS branches that track the Nixpkgs/NixOS channels",
|
||||
"rev": "312a059bef8b29b4db4e73dc02ff441cab7bb26d"
|
||||
},
|
||||
"niv": {
|
||||
"homepage": "https://github.com/nmattia/niv",
|
||||
"url": "https://github.com/nmattia/niv/archive/5d9e3a5f7d51765f0369a4682770ec57d863f19f.tar.gz",
|
||||
"owner": "nmattia",
|
||||
"branch": "master",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
|
||||
"repo": "niv",
|
||||
"type": "tarball",
|
||||
"sha256": "0x7d2rb89h0h7g8sjsgax6ncvf2wwbmxkgvlfi53d00kxj6kfzba",
|
||||
"description": "Easy dependency management for Nix projects",
|
||||
"rev": "5d9e3a5f7d51765f0369a4682770ec57d863f19f"
|
||||
}
|
||||
}
|
||||
67
nix/sources.nix
Normal file
67
nix/sources.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# This file has been generated by Niv.
|
||||
|
||||
# A record, from name to path, of the third-party packages
|
||||
with rec
|
||||
{
|
||||
pkgs =
|
||||
if hasNixpkgsPath
|
||||
then
|
||||
if hasThisAsNixpkgsPath
|
||||
then import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {}
|
||||
else import <nixpkgs> {}
|
||||
else
|
||||
import (builtins_fetchTarball { inherit (sources_nixpkgs) url sha256; }) {};
|
||||
|
||||
sources_nixpkgs =
|
||||
if builtins.hasAttr "nixpkgs" sources
|
||||
then sources.nixpkgs
|
||||
else abort
|
||||
''
|
||||
Please specify either <nixpkgs> (through -I or NIX_PATH=nixpkgs=...) or
|
||||
add a package called "nixpkgs" to your sources.json.
|
||||
'';
|
||||
|
||||
builtins_fetchTarball =
|
||||
# fetchTarball version that is compatible between all the versions of
|
||||
# Nix
|
||||
{ url, sha256 }@attrs:
|
||||
let
|
||||
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||
in
|
||||
if lessThan nixVersion "1.12" then
|
||||
fetchTarball { inherit url; }
|
||||
else
|
||||
fetchTarball attrs;
|
||||
|
||||
hasNixpkgsPath = (builtins.tryEval <nixpkgs>).success;
|
||||
hasThisAsNixpkgsPath =
|
||||
(builtins.tryEval <nixpkgs>).success && <nixpkgs> == ./.;
|
||||
|
||||
sources = builtins.fromJSON (builtins.readFile ./sources.json);
|
||||
|
||||
mapAttrs = builtins.mapAttrs or
|
||||
(f: set: with builtins;
|
||||
listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)));
|
||||
|
||||
getFetcher = spec:
|
||||
let fetcherName =
|
||||
if builtins.hasAttr "type" spec
|
||||
then builtins.getAttr "type" spec
|
||||
else "tarball";
|
||||
in builtins.getAttr fetcherName {
|
||||
"tarball" = pkgs.fetchzip;
|
||||
"file" = pkgs.fetchurl;
|
||||
};
|
||||
};
|
||||
# NOTE: spec must _not_ have an "outPath" attribute
|
||||
mapAttrs (_: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in sources.json should not have an 'outPath' attribute"
|
||||
else
|
||||
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
|
||||
then
|
||||
spec //
|
||||
{ outPath = getFetcher spec { inherit (spec) url sha256; } ; }
|
||||
else spec
|
||||
) sources
|
||||
5
shell.nix
Normal file
5
shell.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{ pkgs ? import ./nix {}}:
|
||||
pkgs.mkShell {
|
||||
name = "dev-shell";
|
||||
buildInputs = [ pkgs.niv ];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue