nix: add channel configuration and rework update process
This commit is contained in:
parent
239c2c9c44
commit
dd4cd9aaf4
14 changed files with 137 additions and 51 deletions
28
Justfile
28
Justfile
|
@ -1,33 +1,45 @@
|
||||||
|
_usage:
|
||||||
|
just -l
|
||||||
|
|
||||||
_device action dir +moreargs="":
|
_device action dir +moreargs="":
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -ex
|
||||||
sudo $(nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A {{action}} --argstr dir {{dir}} {{moreargs}} )
|
sudo $(set -x; nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A {{action}} --argstr dir {{dir}} {{moreargs}})
|
||||||
|
|
||||||
|
_rebuild-device dir rebuildarg="dry-activate" +moreargs="":
|
||||||
|
just -v _device rebuild {{dir}} --argstr rebuildarg {{rebuildarg}} {{moreargs}}
|
||||||
|
|
||||||
_rebuild-device dir rebuildarg="dry-activate":
|
|
||||||
just -v _device rebuild {{dir}} --argstr rebuildarg {{rebuildarg}}
|
|
||||||
|
|
||||||
# Rebulid this device's NixOS
|
# Rebulid this device's NixOS
|
||||||
rebuild-this-device rebuildarg="dry-activate":
|
rebuild-this-device rebuildarg="dry-activate":
|
||||||
just -v _rebuild-device nix/os/devices/$(hostname -s) {{rebuildarg}}
|
just -v _rebuild-device nix/os/devices/$(hostname -s) {{rebuildarg}}
|
||||||
|
|
||||||
|
# This could be used to inject another channel
|
||||||
|
# --argstr moreargs "\'-I nixos-unstable=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz\'"
|
||||||
|
|
||||||
|
|
||||||
# Update nix-channels and switch to updated NixOS and home environments
|
# Update nix-channels and switch to updated NixOS and home environments
|
||||||
update-this-device:
|
update-this-device:
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
export SYSUPDATE_LOG=.$(hostname -s)_sysupdate.log
|
||||||
|
export HOMEUPDATE_LOG=.$(hostname -s)_homeupdate.log
|
||||||
|
|
||||||
echo Updating system channels...
|
echo Updating system channels...
|
||||||
sudo nix-channel --update > .$(hostname -s)_sysupdate.log 2>&1
|
sudo nix-channel --update > ${SYSUPDATE_LOG} 2>&1
|
||||||
echo Updating system...
|
echo Updating system...
|
||||||
if just -v rebuild-this-device >> .$(hostname -s)_sysupdate.log 2>&1 ; then
|
if just -v rebuild-this-device switch >> ${SYSUPDATE_LOG} 2>&1 ; then
|
||||||
echo System update successful
|
echo System update successful
|
||||||
else
|
else
|
||||||
System update failed
|
cat ${SYSUPDATE_LOG}
|
||||||
|
echo System update failed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if type home-manager > /dev/null 2>&1; then
|
if type home-manager > /dev/null 2>&1; then
|
||||||
echo Updating home...
|
echo Updating home...
|
||||||
if home-manager -v switch > .$(hostname -s)_homeupdate.log 2>&1 ; then
|
if home-manager -v switch > ${HOMEUPDATE_LOG} 2>&1 ; then
|
||||||
echo Home update successful
|
echo Home update successful
|
||||||
else
|
else
|
||||||
|
cat ${HOMEUPDATE_LOG}
|
||||||
echo Home update failed
|
echo Home update failed
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
... }:
|
... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
unstablepkgs = import <nixos-unstable> { config = config.nixpkgs.config; };
|
||||||
unstablepkgs = import <nixos-unstable> {};
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
../profiles/common.nix
|
../profiles/common.nix
|
||||||
|
@ -53,11 +51,15 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
||||||
|
# unstablepkgs = import <nixos-unstable> { config = { allowUnfree = true; }; };
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
};
|
};
|
||||||
|
|
||||||
home.packages = []
|
|
||||||
++ (with pkgs; [
|
home.packages =
|
||||||
|
[] ++ (with pkgs; [
|
||||||
# Authentication
|
# Authentication
|
||||||
cacert
|
cacert
|
||||||
fprintd
|
fprintd
|
||||||
|
@ -67,12 +69,10 @@ in {
|
||||||
# Nix package related tools
|
# Nix package related tools
|
||||||
patchelf
|
patchelf
|
||||||
nix-index
|
nix-index
|
||||||
nox
|
|
||||||
nix-prefetch-scripts
|
nix-prefetch-scripts
|
||||||
|
|
||||||
# Version Control Systems
|
# Version Control Systems
|
||||||
git-crypt
|
git-crypt
|
||||||
unstablepkgs.pijul
|
|
||||||
gitFull
|
gitFull
|
||||||
gitless
|
gitless
|
||||||
mr
|
mr
|
||||||
|
|
35
nix/home-manager/configuration/root.nix
Normal file
35
nix/home-manager/configuration/root.nix
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{ pkgs
|
||||||
|
, config,
|
||||||
|
... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
# gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
||||||
|
# unstablepkgs = import <nixos-unstable> {};
|
||||||
|
|
||||||
|
in {
|
||||||
|
imports = [
|
||||||
|
../profiles/common.nix
|
||||||
|
../profiles/nix-channels.nix
|
||||||
|
../programs/neovim.nix
|
||||||
|
../programs/zsh.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
nixpkgs.config = {
|
||||||
|
packageOverrides = pkgs: with pkgs; {
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home.sessionVariables = {
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = []
|
||||||
|
++ (with pkgs; [
|
||||||
|
# Authentication
|
||||||
|
mkpasswd
|
||||||
|
|
||||||
|
# Version Control Systems
|
||||||
|
git-crypt
|
||||||
|
gitFull
|
||||||
|
mr
|
||||||
|
]);
|
||||||
|
}
|
|
@ -43,8 +43,6 @@ in {
|
||||||
NIXPKGS_ALLOW_UNFREE = "1";
|
NIXPKGS_ALLOW_UNFREE = "1";
|
||||||
# Don't create .pyc files.
|
# Don't create .pyc files.
|
||||||
PYTHONDONTWRITEBYTECODE = "1";
|
PYTHONDONTWRITEBYTECODE = "1";
|
||||||
|
|
||||||
HOMESHICK_DIR="${pkgs.homeshick}";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.command-not-found.enable = true;
|
programs.command-not-found.enable = true;
|
||||||
|
|
34
nix/home-manager/profiles/nix-channels.nix
Normal file
34
nix/home-manager/profiles/nix-channels.nix
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{ pkgs
|
||||||
|
, config
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
|
||||||
|
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 Moving existing file away...
|
||||||
|
touch $HOME/.nix-channels.dummy
|
||||||
|
mv --backup=numbered $HOME/.nix-channels.dummy $HOME/.nix-channels
|
||||||
|
rm $HOME/.nix-channels
|
||||||
|
fi
|
||||||
|
''};
|
||||||
|
'';
|
||||||
|
|
||||||
|
nixpkgs.config = {
|
||||||
|
|
||||||
|
packageOverrides = pkgs: with pkgs; {
|
||||||
|
homeshick = builtins.fetchGit {
|
||||||
|
url = "https://github.com/andsens/homeshick.git";
|
||||||
|
ref = "master";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,7 +4,14 @@
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
bootstrapRepos = pkgs.writeScript "bootstrapRepos" ''
|
|
||||||
|
in {
|
||||||
|
home.sessionVariables = {
|
||||||
|
HOMESHICK_DIR="${pkgs.homeshick}";
|
||||||
|
};
|
||||||
|
|
||||||
|
home.activation.bootstrapRepos = config.lib.dag.entryAfter ["writeBoundary"] ''
|
||||||
|
$DRY_RUN_CMD ${pkgs.writeScript "activation-script" ''
|
||||||
set -e
|
set -e
|
||||||
echo home-manager path is ${config.home.path}
|
echo home-manager path is ${config.home.path}
|
||||||
echo home is $HOME
|
echo home is $HOME
|
||||||
|
@ -15,15 +22,7 @@ let
|
||||||
# echo Updating homeshick
|
# echo Updating homeshick
|
||||||
# ln -sfT ${pkgs.homeshick} "$HOMESICK_REPOS"/.homeshick
|
# ln -sfT ${pkgs.homeshick} "$HOMESICK_REPOS"/.homeshick
|
||||||
# mv -Tf "$HOMESICK_REPOS"/{.,}homeshick
|
# mv -Tf "$HOMESICK_REPOS"/{.,}homeshick
|
||||||
'';
|
''};
|
||||||
|
|
||||||
in {
|
|
||||||
home.sessionVariables = {
|
|
||||||
HOMESHICK_DIR="${pkgs.homeshick}";
|
|
||||||
};
|
|
||||||
|
|
||||||
home.activation.bootstrapRepos = config.lib.dag.entryAfter ["writeBoundary"] ''
|
|
||||||
$DRY_RUN_CMD ${bootstrapRepos}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nixpkgs.config = {
|
nixpkgs.config = {
|
||||||
|
|
|
@ -23,8 +23,11 @@ in {
|
||||||
. $HOME/.shrc.d/sh_aliases
|
. $HOME/.shrc.d/sh_aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source ${pkgs.homeshick}/homeshick.sh
|
${if builtins.hasAttr "homeshick" pkgs then ''
|
||||||
fpath=(${pkgs.homeshick}/completions $fpath)
|
source ${pkgs.homeshick}/homeshick.sh
|
||||||
|
fpath=(${pkgs.homeshick}/completions $fpath)
|
||||||
|
'' else ''
|
||||||
|
''}
|
||||||
|
|
||||||
# Disable intercepting of ctrl-s and ctrl-q as flow control.
|
# Disable intercepting of ctrl-s and ctrl-q as flow control.
|
||||||
stty stop ''' -ixoff -ixon
|
stty stop ''' -ixoff -ixon
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
{ pkgs ? import <nixpkgs> {}
|
{ pkgs ? import <nixpkgs> {}
|
||||||
, dir
|
, dir
|
||||||
, rebuildarg ? null
|
, rebuildarg
|
||||||
|
, moreargs ? ""
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
diskId = (import ((builtins.getEnv "PWD")+"/${dir}/hw.nix") {}).hardware.encryptedDisk.diskId;
|
diskId = (import ((builtins.getEnv "PWD")+"/${dir}/hw.nix") {}).hardware.encryptedDisk.diskId;
|
||||||
|
GIT_ROOT=''''$(git rev-parse --show-toplevel)'';
|
||||||
|
|
||||||
in {
|
in {
|
||||||
rebuild = pkgs.writeScript "script" ''
|
rebuild = pkgs.writeScript "script" ''
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -xe
|
set -xe
|
||||||
|
|
||||||
pushd ${dir}
|
pushd ${GIT_ROOT}/${dir}
|
||||||
export NIXOS_CONFIG="$PWD"/configuration.nix
|
export NIXOS_CONFIG="$PWD"/configuration.nix
|
||||||
export INSTALL_ROOT="/mnt/$ID-root"
|
export INSTALL_ROOT="/mnt/$ID-root"
|
||||||
|
|
||||||
[[ -e "''${NIXOS_CONFIG}" ]]
|
[[ -e "''${NIXOS_CONFIG}" ]]
|
||||||
|
|
||||||
nixos-rebuild -I nixos-config=''${NIXOS_CONFIG} ${rebuildarg}
|
nixos-rebuild -I nixos-config=''${NIXOS_CONFIG} ${rebuildarg} ${moreargs}
|
||||||
if test -L result; then
|
if test -L result; then
|
||||||
rm result
|
rm result
|
||||||
fi
|
fi
|
||||||
|
@ -52,7 +54,7 @@ in {
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -xe
|
set -xe
|
||||||
ID=${diskId}
|
ID=${diskId}
|
||||||
pushd ${dir}
|
pushd ${GIT_ROOT}/${dir}
|
||||||
export NIXOS_CONFIG="$PWD"/configuration.nix
|
export NIXOS_CONFIG="$PWD"/configuration.nix
|
||||||
export INSTALL_ROOT="/mnt/$ID-root"
|
export INSTALL_ROOT="/mnt/$ID-root"
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,8 @@
|
||||||
... }:
|
... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
|
||||||
unstablepkgs = import <nixos-unstable> {};
|
|
||||||
|
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
nixpkgs.config = {
|
nixpkgs.config = {
|
||||||
allowBroken = false;
|
allowBroken = false;
|
||||||
allowUnfree = true;
|
allowUnfree = true;
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
networking.hostName = "mmc-sandiskultra32gb"; # Define your hostname.
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
networking.hostName = "steveej-rmvbl-mmc-SL32G_0x259093f6"; # Define your hostname.
|
||||||
|
}
|
|
@ -40,4 +40,10 @@
|
||||||
usbutils
|
usbutils
|
||||||
pciutils
|
pciutils
|
||||||
];
|
];
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
"${builtins.fetchGit { url = "https://github.com/rycee/home-manager.git"; ref = "master"; }}/nixos"
|
||||||
|
];
|
||||||
|
|
||||||
|
home-manager.users.root = import ../../../home-manager/configuration/root.nix;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue