From e5d5ef5cb9ee26d9c6a8d56ea0b8f7884b33644a Mon Sep 17 00:00:00 2001 From: Alexander Bantyev Date: Mon, 27 Apr 2020 04:41:54 +0300 Subject: [PATCH] Finalize flake --- Makefile | 7 - bootstrap | 45 ----- build | 24 --- flake.lock | 16 +- flake.nix | 5 - install | 4 - modules/applications/packages.nix | 1 + modules/applications/weechat.nix | 2 +- modules/mailserver.nix | 4 +- modules/secrets.nix | 2 +- nix/sources.json | 273 ------------------------------ nix/sources.nix | 134 --------------- switch | 6 - 13 files changed, 14 insertions(+), 509 deletions(-) delete mode 100644 Makefile delete mode 100755 bootstrap delete mode 100755 build delete mode 100755 install delete mode 100644 nix/sources.json delete mode 100644 nix/sources.nix delete mode 100755 switch diff --git a/Makefile b/Makefile deleted file mode 100644 index 8ac9c6e..0000000 --- a/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -.PHONY: install result -install: result; SHELL=/bin/sh pkexec $$PWD/switch $$PWD - -secret.nix: secret.nix.gpg; gpg -dq $< > $@ - -result: secret.nix; ./build - diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 0b35753..0000000 --- a/bootstrap +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i bash -p git gnupg - -export IN_NIX_SHELL= - -set -ex - -mkdir -p /mnt/home/balsoft/projects -nixos-generate-config --root /mnt -cd /mnt/home/balsoft/projects -[ -d nixos-config ] || git clone ssh://git@github.com/balsoft/nixos-config -cd nixos-config - -touch secret.nix -while [[ ! -s secret.nix ]] -do gpg -dq secret.nix.gpg > secret.nix -done - -[ -s hardware-configuration/$(hostname).nix ] || mv /mnt/etc/nixos/hardware-configuration.nix hardware-configuration/$(hostname).nix - -mkdir -p /home/balsoft -mount --rbind /mnt/home/balsoft /home/balsoft -mount --rbind /mnt/etc/nixos /etc/nixos - -export NIX_PATH= - -nixpkgs=$(nix eval --raw '(import ./nix/sources.nix).nixpkgs') -nix-store --repair-path $nixpkgs # Evaluating doesn't actually add it to store -rm /tmp/nixpkgs -rf -cp -r $nixpkgs /tmp/nixpkgs # Because we lose everything we added to store after we unmount it - -export NIX_PATH=nixpkgs=/tmp/nixpkgs:nixos-config=/etc/nixos/configuration.nix - -nix copy --all --to /mnt --no-require-sigs - -echo The following operation is irreversible. RET to continue. -read - -umount -l /nix/.rw-store || echo "RW-store is not mounted." -mount --rbind /mnt/nix /nix - -nix build -f /tmp/nixpkgs/nixos system --substituters "https://cache.balsoft.ru https://cache.nixos.org" --no-require-sigs -nixos-install --system ./result -cd /mnt/home/balsoft -chown 1000:100 . -R diff --git a/build b/build deleted file mode 100755 index 0cfbf9c..0000000 --- a/build +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -p git -i bash - -unset IN_NIX_SHELL - -nixpkgs=$(nix eval --raw '(import ./nix/sources.nix).nixpkgs') - -nix-store --realise $nixpkgs - -export NIX_PATH=nixpkgs=$nixpkgs:nixos-config="`pwd`" - -if [[ -n $INSIDE_EMACS ]] -then - nix-build $nixpkgs/nixos -A system $@ -else - nix build -f $nixpkgs/nixos system $@ -fi && - { - git add . - d=$(date +%s) - # The quickest way to commit - git commit -t <(echo -n "Update "; echo -n $(git diff HEAD --name-only) | tr "\n" ", ") --no-edit --no-gpg-sign - git tag latestBuild --force - } diff --git a/flake.lock b/flake.lock index 5d59e64..d7003a6 100644 --- a/flake.lock +++ b/flake.lock @@ -185,18 +185,20 @@ }, "nixpkgs_3": { "info": { - "lastModified": 1587944902, - "narHash": "sha256-DS4R0WC23hcfTTuxb3b3lMdTQYaK5z/d+1ue9ZHUdtE=" + "lastModified": 1587452212, + "narHash": "sha256-Sn9xtMrUYmXCT33yQjNh0tWFwY7jF5x4vCUrkcXDMCE=" }, "locked": { - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "92d9d07c61d06c044af0261ab1741340151e4d3b", + "owner": "nixos", + "repo": "nixpkgs-channels", + "rev": "22a3bf9fb9edad917fb6cd1066d58b5e426ee975", "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs-channels", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index b29deb9..8cc0183 100644 --- a/flake.nix +++ b/flake.nix @@ -80,11 +80,6 @@ repo = "weechat-notify-send"; flake = false; }; - secrets = { - type = "path"; - path = "./secret.nix"; - flake = false; - }; }; outputs = { nixpkgs, ... }@inputs: { diff --git a/install b/install deleted file mode 100755 index 54cccf8..0000000 --- a/install +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -p gnumake gnupg -i bash - -make diff --git a/modules/applications/packages.nix b/modules/applications/packages.nix index 3f50300..e1e54cf 100644 --- a/modules/applications/packages.nix +++ b/modules/applications/packages.nix @@ -63,6 +63,7 @@ xdg_utils nheko gitAndTools.hub + git-crypt nix-patch waypipe cachix diff --git a/modules/applications/weechat.nix b/modules/applications/weechat.nix index d0e967b..fb763e4 100644 --- a/modules/applications/weechat.nix +++ b/modules/applications/weechat.nix @@ -8,7 +8,7 @@ let in { home-manager.users.balsoft = { home.file.".weechat/python/autoload/notify_send.py".source = - "${(import ../../nix/sources.nix).weechat-notify-send}/notify_send.py"; + "${inputs.weechat-notify-send}/notify_send.py"; home.file.".weechat/perl/autoload/multiline.pl".source = "${inputs.weechat-scripts}/perl/multiline.pl"; diff --git a/modules/mailserver.nix b/modules/mailserver.nix index 3392697..81fb2c9 100644 --- a/modules/mailserver.nix +++ b/modules/mailserver.nix @@ -1,6 +1,6 @@ -{ pkgs, config, lib, ... }: +{ pkgs, config, lib, inputs, ... }: let - module = toString (import ../nix/sources.nix).simple-nixos-mailserver; + module = toString inputs.simple-nixos-mailserver; readCommandResult = command: builtins.readFile (pkgs.runCommand "cmd" { preferLocalBuild = true; } "echo -n $(${command}) > $out"); diff --git a/modules/secrets.nix b/modules/secrets.nix index 8c91e13..0e864c3 100755 --- a/modules/secrets.nix +++ b/modules/secrets.nix @@ -89,7 +89,7 @@ in rec { }; }; config = let - secretnix = import inputs.secrets; + secretnix = import ../secret.nix; secrets = if isNull secretnix then mapAttrs (n: v: null) options.secrets else diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index f18dfec..0000000 --- a/nix/sources.json +++ /dev/null @@ -1,273 +0,0 @@ -{ - "NUR": { - "branch": "master", - "description": "Nix User Repository: User contributed nix packages [maintainer=@Mic92]", - "homepage": "", - "owner": "nix-community", - "repo": "NUR", - "rev": "ffd4ab4b9e3de6f695dd4501125b6cbe002edc62", - "sha256": "15hw02m5mwbp7smy462kjzzqb4i0g4c5ncc4maq59mhgiy0cdn4x", - "type": "tarball", - "url": "https://github.com/nix-community/NUR/archive/ffd4ab4b9e3de6f695dd4501125b6cbe002edc62.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "UserChrome-Tweaks": { - "branch": "master", - "description": "A community maintained repository of userChrome.css tweaks for Firefox", - "homepage": null, - "owner": "Timvde", - "repo": "UserChrome-Tweaks", - "rev": "76affa52fd040f703fa7cdcc9f0459643c9883d1", - "sha256": "1nz70d1l0mf4zqk5ng1cizzx8r4hxgkkx8wsw93wld3wdyhk7k3a", - "type": "tarball", - "url": "https://github.com/Timvde/UserChrome-Tweaks/archive/76affa52fd040f703fa7cdcc9f0459643c9883d1.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "all-hies": { - "branch": "master", - "description": "Cached Haskell IDE Engine Nix builds for all GHC versions", - "homepage": "", - "owner": "Infinisil", - "repo": "all-hies", - "rev": "4b984030c8080d944372354a7b558c49858057e7", - "sha256": "0109l0ls7gh2gydrgx45168lg45kgmgwaw9jpjm8mwvwd1brssfk", - "type": "tarball", - "url": "https://github.com/Infinisil/all-hies/archive/4b984030c8080d944372354a7b558c49858057e7.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "base16-unclaimed-schemes": { - "branch": "master", - "description": "A collection of themes that have no repositories for homes :(", - "homepage": null, - "owner": "chriskempson", - "repo": "base16-unclaimed-schemes", - "rev": "d6b93456dc1012628faec572387814f59e0b854a", - "sha256": "043ny56snl4w2ri1i0zzfh00zm2gf2h5jz57kgmf5jb9xj0sspb1", - "type": "tarball", - "url": "https://github.com/chriskempson/base16-unclaimed-schemes/archive/d6b93456dc1012628faec572387814f59e0b854a.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "home-manager": { - "branch": "master", - "description": "Manage a user environment using Nix", - "homepage": "", - "owner": "rycee", - "repo": "home-manager", - "rev": "5baa0c300f2c524e2a3f154cf4ee2688ef734f41", - "sha256": "1jsk4q0z4d0wr5hcxkk2z73yyi1dq604whhdpag5nm4sqwm7484p", - "type": "tarball", - "url": "https://github.com/rycee/home-manager/archive/5baa0c300f2c524e2a3f154cf4ee2688ef734f41.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "materia-theme": { - "branch": "master", - "description": "A Material Design theme for GNOME/GTK based desktop environments", - "homepage": "", - "owner": "nana-4", - "repo": "materia-theme", - "rev": "b1e4c563146ae34fff6a697393b6a1bc66b612f5", - "sha256": "1w65v7jl8v5h41d27gj79rnkbn8rw0avrj4gi57l8lvlhpn9q6a2", - "type": "tarball", - "url": "https://github.com/nana-4/materia-theme/archive/b1e4c563146ae34fff6a697393b6a1bc66b612f5.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "mopidy": { - "branch": "v2.3.1", - "description": "Mopidy is an extensible music server written in Python", - "homepage": "https://mopidy.com", - "owner": "mopidy", - "repo": "mopidy", - "rev": "6ee0379b0f4eee0da5721b3c415f520626e56b20", - "sha256": "1qdflxr0an6l2m3j90h55bzyj7rjlkkwmxx945hwv8xi472rcgdj", - "type": "tarball", - "url": "https://github.com/mopidy/mopidy/archive/6ee0379b0f4eee0da5721b3c415f520626e56b20.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "mopidy-gmusic": { - "branch": "master", - "description": "Mopidy extension for playing music from Google Play Music", - "homepage": "https://www.mopidy.com", - "owner": "mopidy", - "repo": "mopidy-gmusic", - "rev": "88e71a18fd8b20b302b990abd97e2bf52cf678b8", - "sha256": "08xi0pn1zvkfy1d27pll1dwj2m08mdf07g1bw4aqz2p59vy67v6v", - "type": "tarball", - "url": "https://github.com/mopidy/mopidy-gmusic/archive/88e71a18fd8b20b302b990abd97e2bf52cf678b8.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "mopidy-youtube": { - "branch": "develop", - "description": "Mopidy extension for playing music from YouTube", - "homepage": "", - "owner": "natumbri", - "repo": "mopidy-youtube", - "rev": "d2d9999111f382ce3cf2f6600701649deadaafde", - "sha256": "1ld1w56nh8b527rr2g3a81dh0lxmabvn2pa3y8kv22m2vjbr7b04", - "type": "tarball", - "url": "https://github.com/natumbri/mopidy-youtube/archive/d2d9999111f382ce3cf2f6600701649deadaafde.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "mtxclient": { - "branch": "0.3.0-dev", - "description": "Client API library for Matrix, built on top of Boost.Asio", - "homepage": "", - "owner": "nheko-reborn", - "repo": "mtxclient", - "rev": "84c6778cc367bca79755e73e77b2cc69950375b2", - "sha256": "13h5a0kdsirsfrgvmyi0r441cbjx247ymif5gk1b35h27vk1613k", - "type": "tarball", - "url": "https://github.com/nheko-reborn/mtxclient/archive/84c6778cc367bca79755e73e77b2cc69950375b2.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nheko": { - "branch": "0.7.0-dev", - "description": "Desktop client for Matrix using Qt and C++14.", - "homepage": "", - "owner": "nheko-reborn", - "repo": "nheko", - "rev": "1943d1c74d5253ec9d2b7ee38f69d791d28e84c1", - "sha256": "1r9fm3wzcw8jcg5amabpdj5rs3099dcx1mw1r6j559s9ymcfimwi", - "type": "tarball", - "url": "https://github.com/nheko-reborn/nheko/archive/1943d1c74d5253ec9d2b7ee38f69d791d28e84c1.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "49157afd2298749b8a5062fd21079542a6b2de35", - "sha256": "0q7ymfrcgagcsw6kr93kprag7k358qj8znyzyri53ci1mrsak5y1", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/49157afd2298749b8a5062fd21079542a6b2de35.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixfmt": { - "branch": "master", - "description": "A formatter for Nix code", - "homepage": "https://nixfmt.serokell.io", - "owner": "serokell", - "repo": "nixfmt", - "rev": "921bbd3bb9c95cf2d677a8558b1a27fca6cee597", - "sha256": "0x08xsjal6db95y1sxxinwv9ks2k6fayvg8435s6zqy7zq42jxm4", - "type": "tarball", - "url": "https://github.com/serokell/nixfmt/archive/921bbd3bb9c95cf2d677a8558b1a27fca6cee597.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixos-unstable", - "builtin": false, - "description": "The nix packages collection stable", - "homepage": "https://github.com/nixos/nixpkgs", - "owner": "nixos", - "repo": "nixpkgs-channels", - "rev": "22a3bf9fb9edad917fb6cd1066d58b5e426ee975", - "sha256": "089hqg2r2ar5piw9q5z3iv0qbmfjc4rl5wkx9z16aqnlras72zsa", - "type": "tarball", - "url": "https://github.com/nixos/nixpkgs-channels/archive/22a3bf9fb9edad917fb6cd1066d58b5e426ee975.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs-old": { - "branch": "nixos-19.03", - "description": "Nix Packages collection", - "homepage": null, - "owner": "nixos", - "repo": "nixpkgs", - "rev": "c8db7a8a16ee9d54103cade6e766509e1d1c8d7b", - "sha256": "1b3h4mwpi10blzpvgsc0191k4shaw3nw0qd2p82hygbr8vv4g9dv", - "type": "tarball", - "url": "https://github.com/nixos/nixpkgs/archive/c8db7a8a16ee9d54103cade6e766509e1d1c8d7b.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs-unstable": { - "branch": "nixos-unstable", - "description": "The nix packages collection unstable", - "homepage": "https://github.com/nixos/nixpkgs", - "owner": "nixos", - "repo": "nixpkgs-channels", - "rev": "22a3bf9fb9edad917fb6cd1066d58b5e426ee975", - "sha256": "089hqg2r2ar5piw9q5z3iv0qbmfjc4rl5wkx9z16aqnlras72zsa", - "type": "tarball", - "url": "https://github.com/nixos/nixpkgs-channels/archive/22a3bf9fb9edad917fb6cd1066d58b5e426ee975.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "pykka": { - "branch": "v2.0.1", - "description": "Pykka is a Python implementation of the actor model, which makes it easier to build concurrent applications", - "homepage": "https://www.pykka.org", - "owner": "jodal", - "repo": "pykka", - "rev": "1982e1caf63726c66b28616c80d548ae1bb4fe87", - "sha256": "011rvv3vzj9rpwaq6vfpz9hfwm6gx1jmad4iri6z12g8nnlpydhs", - "type": "tarball", - "url": "https://github.com/jodal/pykka/archive/1982e1caf63726c66b28616c80d548ae1bb4fe87.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "scripts": { - "branch": "master", - "description": "Official scripts for WeeChat.", - "homepage": "https://weechat.org/scripts/", - "owner": "weechat", - "repo": "scripts", - "rev": "a69d3ff2fce34958f78395a85c0b8676f3d03b15", - "sha256": "1x88bvdi9pqvpfqqwp8q59ic2ia937q07hcj2dkia17ncj2v27wd", - "type": "tarball", - "url": "https://github.com/weechat/scripts/archive/a69d3ff2fce34958f78395a85c0b8676f3d03b15.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "simple-nixos-mailserver": { - "sha256": "08wcwc54b1k9gnx5z97yv4gm28lx50vnnsvk93l98zq209rpf7rq", - "type": "tarball", - "url": "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/0bf2bb0b54736df944c657a15069d19e01ab78a8/nixos-mailserver-0bf2bb0b54736df944c657a15069d19e01ab78a8.tar.gz", - "url_template": "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/0bf2bb0b54736df944c657a15069d19e01ab78a8/nixos-mailserver-0bf2bb0b54736df944c657a15069d19e01ab78a8.tar.gz" - }, - "sway": { - "branch": "master", - "description": "i3-compatible Wayland compositor", - "homepage": "https://swaywm.org/", - "owner": "swaywm", - "repo": "sway", - "rev": "ab77efc6caba50acc4c87e02ae3e6712ea808772", - "sha256": "1wmjv8sj4zkmcfgfk5can2zmnq2dxggh2viaw575hzbn34nxi2pz", - "type": "tarball", - "url": "https://github.com/swaywm/sway/archive/ab77efc6caba50acc4c87e02ae3e6712ea808772.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "weechat-notify-send": { - "branch": "master", - "description": "A WeeChat script that sends highlight and message notifications through notify-send.", - "homepage": "", - "owner": "s3rvac", - "repo": "weechat-notify-send", - "rev": "b491e6acc1fe00fd1b91409444f9904587b2e588", - "sha256": "1f9558a78ismd645c9v6p3lgda6hkgn3f63i8s4y5r8zdymx08d0", - "type": "tarball", - "url": "https://github.com/s3rvac/weechat-notify-send/archive/b491e6acc1fe00fd1b91409444f9904587b2e588.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "wl-clipboard": { - "branch": "master", - "description": "Command-line copy/paste utilities for Wayland", - "homepage": "", - "owner": "bugaevc", - "repo": "wl-clipboard", - "rev": "f3a45f69f7d14e7f7050bca4cbf6fea6697d1455", - "sha256": "0c4w87ipsw09aii34szj9p0xfy0m00wyjpll0gb0aqmwa60p0c5d", - "type": "tarball", - "url": "https://github.com/bugaevc/wl-clipboard/archive/f3a45f69f7d14e7f7050bca4cbf6fea6697d1455.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "wlroots": { - "branch": "master", - "description": "A modular Wayland compositor library", - "homepage": "https://swaywm.org", - "owner": "swaywm", - "repo": "wlroots", - "rev": "57ffb35de009611d8edecb297bc2fd10a9a86702", - "sha256": "0c0q1p9yss5kx4430ik3n89drqpmm2bvgl8fjlf6prac1a7xzqn8", - "type": "tarball", - "url": "https://github.com/swaywm/wlroots/archive/57ffb35de009611d8edecb297bc2fd10a9a86702.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 8a725cb..0000000 --- a/nix/sources.nix +++ /dev/null @@ -1,134 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: spec: - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; } - else - pkgs.fetchurl { inherit (spec) url sha256; }; - - fetch_tarball = pkgs: spec: - if spec.builtin or true then - builtins_fetchTarball { inherit (spec) url sha256; } - else - pkgs.fetchzip { inherit (spec) url sha256; }; - - fetch_git = spec: - builtins.fetchGit { url = spec.repo; inherit (spec) rev ref; }; - - fetch_builtin-tarball = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-tarball" will soon be deprecated. You should - instead use `builtin = true`. - - $ niv modify -a type=tarball -a builtin=true - '' - builtins_fetchTarball { inherit (spec) url sha256; }; - - fetch_builtin-url = spec: - builtins.trace - '' - WARNING: - The niv type "builtin-url" will soon be deprecated. You should - instead use `builtin = true`. - - $ niv modify -a type=file -a builtin=true - '' - (builtins_fetchurl { inherit (spec) url sha256; }); - - # - # Various helpers - # - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) {}; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs spec - else if spec.type == "tarball" then fetch_tarball pkgs spec - else if spec.type == "git" then fetch_git spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball spec - else if spec.type == "builtin-url" then fetch_builtin-url spec - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # 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; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = fetch config.pkgs name spec; } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? ./sources.json - , sources ? builtins.fromJSON (builtins.readFile sourcesFile) - , pkgs ? mkPkgs sources - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/switch b/switch deleted file mode 100755 index 240571a..0000000 --- a/switch +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -PATH=/run/current-system/sw/bin - -nix-env --profile /nix/var/nix/profiles/system --set $(readlink $1/result) -$1/result/bin/switch-to-configuration switch