nix,steveej-t480s-work: introduce pure versioning
This commit is contained in:
parent
17c8ccb8c2
commit
c5c4b160a1
12 changed files with 55 additions and 13 deletions
5
Justfile
5
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
|
||||
|
|
25
nix/default.nix
Normal file
25
nix/default.nix
Normal file
|
@ -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}
|
||||
'';
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
let
|
||||
# gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
||||
unstablepkgs = import <nixos-unstable> { config = config.nixpkgs.config; };
|
||||
unstablepkgs = import <channels-nixos-unstable> { config = config.nixpkgs.config; };
|
||||
|
||||
in {
|
||||
imports = [
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
... }:
|
||||
|
||||
let
|
||||
unstablepkgs = import <nixos-unstable> { config = config.nixpkgs.config; };
|
||||
unstablepkgs = import <channels-nixos-unstable> { config = config.nixpkgs.config; };
|
||||
|
||||
in {
|
||||
imports = [
|
||||
../profiles/common.nix
|
||||
|
@ -52,9 +53,6 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
# gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
||||
# unstablepkgs = import <nixos-unstable> { config = { allowUnfree = true; }; };
|
||||
|
||||
home.sessionVariables = {
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
}:
|
||||
|
||||
let
|
||||
unstablepkgs = import <nixos-unstable> {};
|
||||
unstablepkgs = import <channels-nixos-unstable> {};
|
||||
|
||||
in {
|
||||
home.sessionVariables = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ pkgs ? import <nixpkgs> {}
|
||||
{ pkgs ? import <channels-nixos-stable> {}
|
||||
, ownLib ? import ../lib/default.nix { }
|
||||
, dir
|
||||
, rebuildarg
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
}:
|
||||
|
||||
let
|
||||
unstablepkgs = import <nixos-unstable> { config = config.nixpkgs; };
|
||||
unstablepkgs = import <channels-nixos-unstable> { config = config.nixpkgs; };
|
||||
|
||||
in {
|
||||
# The NixOS release to be compatible with for stateful data such as databases.
|
||||
|
|
4
nix/os/devices/steveej-t480s-work/versions.nix
Normal file
4
nix/os/devices/steveej-t480s-work/versions.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
channelsNixosStable = "7e88992a8c7b2de0bcb89182d8686b27bd93e46a";
|
||||
channelsNixosUnstable = "44b02b52ea6a49674f124f50009299f192ed78bb";
|
||||
}
|
|
@ -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 <nixpkgs> {}' --arg config 'null' 2>&1 | grep -oE '[0-9a-z]{52}' | head -n1)
|
||||
hash=$(nix-build ${INFILE} --arg pkgs 'import <channels-nixos-stable> {}' --arg config 'null' 2>&1 | grep -oE '[0-9a-z]{52}' | head -n1)
|
||||
sed -E "s/0{52}/${hash}/" ${INFILE} > ${OUTFILE}
|
||||
|
|
4
nix/variables/versions.nix
Normal file
4
nix/variables/versions.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
channelsNixosStable = "7e88992a8c7b2de0bcb89182d8686b27bd93e46a";
|
||||
channelsNixosUnstable = "44b02b52ea6a49674f124f50009299f192ed78bb";
|
||||
}
|
|
@ -1,12 +1,15 @@
|
|||
with import <nixpkgs> {};
|
||||
{ ... }:
|
||||
|
||||
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 <nixpkgs/nixos> { 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue