diff --git a/Justfile b/Justfile index 27a0c4f..01e5a23 100755 --- a/Justfile +++ b/Justfile @@ -1,14 +1,19 @@ _usage: just -l +_get_nix_path versionsPath: + echo $(set -x; nix-build --no-link --show-trace {{invocation_directory()}}/nix/default.nix -A channelSources --argstr versionsPath {{versionsPath}} --argstr rebuildarg "dummy") + _device recipe dir +moreargs="": #!/usr/bin/env bash set -ex + source $(just -v _get_nix_path {{invocation_directory()}}/{{dir}}/versions.nix) $(set -x; nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A recipes.{{recipe}} --argstr dir {{dir}} {{moreargs}}) _render_templates: #!/usr/bin/env bash set -ex + source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix) nix/scripts/pre-eval-fixed.sh nix/home-manager/profiles/dotfiles/vcsh{.tmpl,}.nix _rebuild-device dir rebuildarg="dry-activate" +moreargs="": _render_templates diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..6cb96b4 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,25 @@ +{ versionsPath }: + +{ + channelSources = + let + # channelVersions = (import ((builtins.getEnv "PWD")+"/${dir}/versions.nix")); + channelVersions = (import versionsPath); + mkChannelSource = channel: builtins.fetchGit { + # Descriptive name to make the store path easier to identify + url = "https://github.com/NixOS/nixpkgs-channels/"; + # Commit hash for nixos-unstable as of 2018-09-12 + # `git ls-remote https://github.com/nixos/nixpkgs-channels nixos-unstable` + rev = (builtins.getAttr channel channelVersions); + name = "nixpkgs-channels-${channel}"; + }; + nix_path = builtins.foldl' (sum: elem: sum +":" + builtins.concatStringsSep "=" elem) "" [ + [ "nixpkgs" (mkChannelSource "channelsNixosStable") ] + [ "nixos" (mkChannelSource "channelsNixosStable") ] + [ "channels-nixos-stable" (mkChannelSource "channelsNixosStable") ] + [ "channels-nixos-unstable" (mkChannelSource "channelsNixosUnstable") ] + ]; + in (import (mkChannelSource "channelsNixosStable") {}).writeText "channels.rc" '' + export NIX_PATH=${nix_path} + ''; + } diff --git a/nix/home-manager/configuration/graphical-fullblown.nix b/nix/home-manager/configuration/graphical-fullblown.nix index 4007ddd..2c56230 100644 --- a/nix/home-manager/configuration/graphical-fullblown.nix +++ b/nix/home-manager/configuration/graphical-fullblown.nix @@ -4,7 +4,7 @@ let # gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {}; - unstablepkgs = import { config = config.nixpkgs.config; }; + unstablepkgs = import { config = config.nixpkgs.config; }; in { imports = [ diff --git a/nix/home-manager/configuration/graphical-removable.nix b/nix/home-manager/configuration/graphical-removable.nix index aade69f..1cbf3ac 100644 --- a/nix/home-manager/configuration/graphical-removable.nix +++ b/nix/home-manager/configuration/graphical-removable.nix @@ -3,7 +3,8 @@ ... }: let - unstablepkgs = import { config = config.nixpkgs.config; }; + unstablepkgs = import { config = config.nixpkgs.config; }; + in { imports = [ ../profiles/common.nix @@ -52,9 +53,6 @@ in { }; }; - # gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {}; - # unstablepkgs = import { config = { allowUnfree = true; }; }; - home.sessionVariables = { }; diff --git a/nix/home-manager/profiles/nix-channels.nix b/nix/home-manager/profiles/nix-channels.nix index faa9984..4a0eebe 100644 --- a/nix/home-manager/profiles/nix-channels.nix +++ b/nix/home-manager/profiles/nix-channels.nix @@ -6,14 +6,16 @@ let in { home.file.".nix-channels".text = '' - https://nixos.org/channels/nixos-18.09 nixos - https://nixos.org/channels/nixos-unstable nixos-unstable ''; home.activation.removeExistingNixChannels = config.lib.dag.entryBefore ["checkLinkTargets"] '' $DRY_RUN_CMD ${pkgs.writeScript "activation-script" '' set -ex if test -f $HOME/.nix-channels; then + echo Uninstalling available channels... + while read url channel; do + nix-channel --remove $channel + done < $HOME/.nix-channel echo Moving existing file away... touch $HOME/.nix-channels.dummy mv --backup=numbered $HOME/.nix-channels.dummy $HOME/.nix-channels diff --git a/nix/home-manager/programs/neovim.nix b/nix/home-manager/programs/neovim.nix index 8b5a343..b298be4 100644 --- a/nix/home-manager/programs/neovim.nix +++ b/nix/home-manager/programs/neovim.nix @@ -3,7 +3,7 @@ }: let - unstablepkgs = import {}; + unstablepkgs = import {}; in { home.sessionVariables = { diff --git a/nix/os/devices/default.nix b/nix/os/devices/default.nix index 462f1ee..5b58d94 100644 --- a/nix/os/devices/default.nix +++ b/nix/os/devices/default.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} +{ pkgs ? import {} , ownLib ? import ../lib/default.nix { } , dir , rebuildarg diff --git a/nix/os/devices/steveej-laptop/system.nix b/nix/os/devices/steveej-laptop/system.nix index 1f55f91..ae87f1d 100644 --- a/nix/os/devices/steveej-laptop/system.nix +++ b/nix/os/devices/steveej-laptop/system.nix @@ -5,7 +5,7 @@ }: let - unstablepkgs = import { config = config.nixpkgs; }; + unstablepkgs = import { config = config.nixpkgs; }; in { # The NixOS release to be compatible with for stateful data such as databases. diff --git a/nix/os/devices/steveej-t480s-work/versions.nix b/nix/os/devices/steveej-t480s-work/versions.nix new file mode 100644 index 0000000..57f56b6 --- /dev/null +++ b/nix/os/devices/steveej-t480s-work/versions.nix @@ -0,0 +1,4 @@ +{ + channelsNixosStable = "7e88992a8c7b2de0bcb89182d8686b27bd93e46a"; + channelsNixosUnstable = "44b02b52ea6a49674f124f50009299f192ed78bb"; +} diff --git a/nix/scripts/pre-eval-fixed.sh b/nix/scripts/pre-eval-fixed.sh index 0b22a4f..314346f 100755 --- a/nix/scripts/pre-eval-fixed.sh +++ b/nix/scripts/pre-eval-fixed.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +set -xe INFILE="${1:?Please set arg1 to INFILE}" OUTFILE="${2:?Please set arg2 to OUTFILE}" -hash=$(nix-build ${INFILE} --arg pkgs 'import {}' --arg config 'null' 2>&1 | grep -oE '[0-9a-z]{52}' | head -n1) +hash=$(nix-build ${INFILE} --arg pkgs 'import {}' --arg config 'null' 2>&1 | grep -oE '[0-9a-z]{52}' | head -n1) sed -E "s/0{52}/${hash}/" ${INFILE} > ${OUTFILE} diff --git a/nix/variables/versions.nix b/nix/variables/versions.nix new file mode 100644 index 0000000..57f56b6 --- /dev/null +++ b/nix/variables/versions.nix @@ -0,0 +1,4 @@ +{ + channelsNixosStable = "7e88992a8c7b2de0bcb89182d8686b27bd93e46a"; + channelsNixosUnstable = "44b02b52ea6a49674f124f50009299f192ed78bb"; +} diff --git a/shell.nix b/shell.nix index 1bde9c2..d7104ff 100644 --- a/shell.nix +++ b/shell.nix @@ -1,12 +1,15 @@ -with import {}; +{ ... }: let + channels-nixos-stable-path = (builtins.fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/7e88992a8c7b2de0bcb89182d8686b27bd93e46a.tar.gz); + channels-nixos-stable = import channels-nixos-stable-path {}; in +with channels-nixos-stable; stdenv.mkDerivation { name = "infra-env"; buildInputs = [ - (with import { configuration = {}; }; with config.system.build; [ nixos-generate-config nixos-install nixos-enter manual.manpages ]) + (with import (channels-nixos-stable-path+"/nixos") { configuration = {}; }; with config.system.build; [ nixos-generate-config nixos-install nixos-enter manual.manpages ]) (pkgs.callPackage ./nix/pkgs/just.nix {}) git-crypt vcsh