nix,steveej-t480s-work: introduce pure versioning

This commit is contained in:
steveej 2018-12-17 13:10:06 +01:00
parent 17c8ccb8c2
commit c5c4b160a1
12 changed files with 55 additions and 13 deletions

25
nix/default.nix Normal file
View 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}
'';
}

View file

@ -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 = [

View file

@ -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 = {
};

View file

@ -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

View file

@ -3,7 +3,7 @@
}:
let
unstablepkgs = import <nixos-unstable> {};
unstablepkgs = import <channels-nixos-unstable> {};
in {
home.sessionVariables = {

View file

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {}
{ pkgs ? import <channels-nixos-stable> {}
, ownLib ? import ../lib/default.nix { }
, dir
, rebuildarg

View file

@ -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.

View file

@ -0,0 +1,4 @@
{
channelsNixosStable = "7e88992a8c7b2de0bcb89182d8686b27bd93e46a";
channelsNixosUnstable = "44b02b52ea6a49674f124f50009299f192ed78bb";
}

View file

@ -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}

View file

@ -0,0 +1,4 @@
{
channelsNixosStable = "7e88992a8c7b2de0bcb89182d8686b27bd93e46a";
channelsNixosUnstable = "44b02b52ea6a49674f124f50009299f192ed78bb";
}