WIP: use niv for source management #29
5 changed files with 144 additions and 2 deletions
|
@ -2,6 +2,8 @@ self: super:
|
||||||
|
|
||||||
let
|
let
|
||||||
nixpkgs-master = import <nixpkgs-master> {};
|
nixpkgs-master = import <nixpkgs-master> {};
|
||||||
|
# sources = import ./sources.nix;
|
||||||
|
# nixpkgs-master = sources.nixpkgs-master;
|
||||||
|
|
||||||
# one application requires php5
|
# one application requires php5
|
||||||
nixpkgsWithPhp5 = super.fetchFromGitHub {
|
nixpkgsWithPhp5 = super.fetchFromGitHub {
|
||||||
|
@ -23,8 +25,6 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
podman = nixpkgs-master.podman;
|
podman = nixpkgs-master.podman;
|
||||||
conmon = nixpkgs-master.conmon;
|
conmon = nixpkgs-master.conmon;
|
||||||
|
|
||||||
|
|
8
nix/package-set.nix
Normal file
8
nix/package-set.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ pkgs }:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
let
|
||||||
|
self = foldl'
|
||||||
|
(prev: overlay: prev // (overlay (pkgs // self) (pkgs // prev)))
|
||||||
|
{} (map import (import ./overlays.nix));
|
||||||
|
in self
|
38
nix/sources.json
Normal file
38
nix/sources.json
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{
|
||||||
|
"niv": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "Easy dependency management for Nix projects",
|
||||||
|
"homepage": "https://github.com/nmattia/niv",
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "niv",
|
||||||
|
"rev": "5e9671a9a87c240b1c6ce981d04ad23ba4291451",
|
||||||
|
"sha256": "08j7msxkv452pyxnh0sgn6h9930i5mk9mszba49bj5401gzmfb8a",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nmattia/niv/archive/5e9671a9a87c240b1c6ce981d04ad23ba4291451.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"branch": "nixos-19.03",
|
||||||
|
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
|
||||||
|
"homepage": "https://github.com/NixOS/nixpkgs",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs-channels",
|
||||||
|
"rev": "7339bd47600f687dac692fea897bbf58c55631c4",
|
||||||
|
"sha256": "12nxr39pjhd8n0l91wsv1kvzdsa5zhhc5a0hndbi1zyxjdrlqsxa",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs-channels/archive/7339bd47600f687dac692fea897bbf58c55631c4.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"nixpkgs-master": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "Nix Packages collection",
|
||||||
|
"homepage": null,
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "92e653b19b613bba25cdd7367fe039697d70ecdf",
|
||||||
|
"sha256": "0aiq94nsyxwcal2f7kclb70fggzmw39gkz3l2cs384sv1kw4dmck",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/NixOS/nixpkgs/archive/92e653b19b613bba25cdd7367fe039697d70ecdf.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
}
|
||||||
|
}
|
89
nix/sources.nix
Normal file
89
nix/sources.nix
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
# 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.
|
||||||
|
'';
|
||||||
|
|
||||||
|
# fetchTarball version that is compatible between all the versions of Nix
|
||||||
|
builtins_fetchTarball =
|
||||||
|
{ url, sha256 }@attrs:
|
||||||
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchTarball;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
|
fetchTarball { inherit url; }
|
||||||
|
else
|
||||||
|
fetchTarball attrs;
|
||||||
|
|
||||||
|
# fetchurl version that is compatible between all the versions of Nix
|
||||||
|
builtins_fetchurl =
|
||||||
|
{ url, sha256 }@attrs:
|
||||||
|
let
|
||||||
|
inherit (builtins) lessThan nixVersion fetchurl;
|
||||||
|
in
|
||||||
|
if lessThan nixVersion "1.12" then
|
||||||
|
fetchurl { inherit url; }
|
||||||
|
else
|
||||||
|
fetchurl attrs;
|
||||||
|
|
||||||
|
# A wrapper around pkgs.fetchzip that has inspectable arguments,
|
||||||
|
# annoyingly this means we have to specify them
|
||||||
|
fetchzip = { url, sha256 }@attrs: pkgs.fetchzip 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)));
|
||||||
|
|
||||||
|
# borrowed from nixpkgs
|
||||||
|
functionArgs = f: f.__functionArgs or (builtins.functionArgs f);
|
||||||
|
callFunctionWith = autoArgs: f: args:
|
||||||
|
let auto = builtins.intersectAttrs (functionArgs f) autoArgs;
|
||||||
|
in f (auto // args);
|
||||||
|
|
||||||
|
getFetcher = spec:
|
||||||
|
let fetcherName =
|
||||||
|
if builtins.hasAttr "type" spec
|
||||||
|
then builtins.getAttr "type" spec
|
||||||
|
else "builtin-tarball";
|
||||||
|
in builtins.getAttr fetcherName {
|
||||||
|
"tarball" = fetchzip;
|
||||||
|
"builtin-tarball" = builtins_fetchTarball;
|
||||||
|
"file" = pkgs.fetchurl;
|
||||||
|
"builtin-url" = builtins_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 = callFunctionWith spec (getFetcher spec) { }; }
|
||||||
|
else spec
|
||||||
|
) sources
|
|
@ -4,6 +4,12 @@ let
|
||||||
channels-nixos-stable-path = (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/7e88992a8c7b2de0bcb89182d8686b27bd93e46a.tar.gz);
|
channels-nixos-stable-path = (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/7e88992a8c7b2de0bcb89182d8686b27bd93e46a.tar.gz);
|
||||||
channels-nixos-stable = import channels-nixos-stable-path { overlays = [ (import ./nix/overlay.nix) ]; };
|
channels-nixos-stable = import channels-nixos-stable-path { overlays = [ (import ./nix/overlay.nix) ]; };
|
||||||
|
|
||||||
|
niv = (import (channels-nixos-stable.fetchFromGitHub {
|
||||||
|
owner = "nmattia";
|
||||||
|
repo = "niv";
|
||||||
|
rev = "5e9671a9a87c240b1c6ce981d04ad23ba4291451";
|
||||||
|
sha256 = "08j7msxkv452pyxnh0sgn6h9930i5mk9mszba49bj5401gzmfb8a";
|
||||||
|
}) {}).niv;
|
||||||
in
|
in
|
||||||
with channels-nixos-stable;
|
with channels-nixos-stable;
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
@ -26,6 +32,7 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
alacritty
|
alacritty
|
||||||
|
niv
|
||||||
];
|
];
|
||||||
|
|
||||||
# Set Environment Variables
|
# Set Environment Variables
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue