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="":
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
sudo $(nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A {{action}} --argstr dir {{dir}} {{moreargs}} )
|
||||
set -ex
|
||||
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
|
||||
rebuild-this-device rebuildarg="dry-activate":
|
||||
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-this-device:
|
||||
#!/usr/bin/env bash
|
||||
export SYSUPDATE_LOG=.$(hostname -s)_sysupdate.log
|
||||
export HOMEUPDATE_LOG=.$(hostname -s)_homeupdate.log
|
||||
|
||||
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...
|
||||
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
|
||||
else
|
||||
System update failed
|
||||
cat ${SYSUPDATE_LOG}
|
||||
echo System update failed
|
||||
fi
|
||||
|
||||
if type home-manager > /dev/null 2>&1; then
|
||||
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
|
||||
else
|
||||
cat ${HOMEUPDATE_LOG}
|
||||
echo Home update failed
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
... }:
|
||||
|
||||
let
|
||||
# gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
||||
unstablepkgs = import <nixos-unstable> {};
|
||||
|
||||
unstablepkgs = import <nixos-unstable> { config = config.nixpkgs.config; };
|
||||
in {
|
||||
imports = [
|
||||
../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.packages = []
|
||||
++ (with pkgs; [
|
||||
|
||||
home.packages =
|
||||
[] ++ (with pkgs; [
|
||||
# Authentication
|
||||
cacert
|
||||
fprintd
|
||||
|
@ -67,12 +69,10 @@ in {
|
|||
# Nix package related tools
|
||||
patchelf
|
||||
nix-index
|
||||
nox
|
||||
nix-prefetch-scripts
|
||||
|
||||
# Version Control Systems
|
||||
git-crypt
|
||||
unstablepkgs.pijul
|
||||
gitFull
|
||||
gitless
|
||||
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";
|
||||
# Don't create .pyc files.
|
||||
PYTHONDONTWRITEBYTECODE = "1";
|
||||
|
||||
HOMESHICK_DIR="${pkgs.homeshick}";
|
||||
};
|
||||
|
||||
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
|
||||
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
|
||||
echo home-manager path is ${config.home.path}
|
||||
echo home is $HOME
|
||||
|
@ -15,15 +22,7 @@ let
|
|||
# echo Updating homeshick
|
||||
# ln -sfT ${pkgs.homeshick} "$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 = {
|
||||
|
|
|
@ -23,8 +23,11 @@ in {
|
|||
. $HOME/.shrc.d/sh_aliases
|
||||
fi
|
||||
|
||||
source ${pkgs.homeshick}/homeshick.sh
|
||||
fpath=(${pkgs.homeshick}/completions $fpath)
|
||||
${if builtins.hasAttr "homeshick" pkgs then ''
|
||||
source ${pkgs.homeshick}/homeshick.sh
|
||||
fpath=(${pkgs.homeshick}/completions $fpath)
|
||||
'' else ''
|
||||
''}
|
||||
|
||||
# Disable intercepting of ctrl-s and ctrl-q as flow control.
|
||||
stty stop ''' -ixoff -ixon
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
{ pkgs ? import <nixpkgs> {}
|
||||
, dir
|
||||
, rebuildarg ? null
|
||||
, rebuildarg
|
||||
, moreargs ? ""
|
||||
}:
|
||||
|
||||
let
|
||||
diskId = (import ((builtins.getEnv "PWD")+"/${dir}/hw.nix") {}).hardware.encryptedDisk.diskId;
|
||||
GIT_ROOT=''''$(git rev-parse --show-toplevel)'';
|
||||
|
||||
in {
|
||||
rebuild = pkgs.writeScript "script" ''
|
||||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
|
||||
pushd ${dir}
|
||||
pushd ${GIT_ROOT}/${dir}
|
||||
export NIXOS_CONFIG="$PWD"/configuration.nix
|
||||
export INSTALL_ROOT="/mnt/$ID-root"
|
||||
|
||||
[[ -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
|
||||
rm result
|
||||
fi
|
||||
|
@ -52,7 +54,7 @@ in {
|
|||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
ID=${diskId}
|
||||
pushd ${dir}
|
||||
pushd ${GIT_ROOT}/${dir}
|
||||
export NIXOS_CONFIG="$PWD"/configuration.nix
|
||||
export INSTALL_ROOT="/mnt/$ID-root"
|
||||
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
... }:
|
||||
|
||||
let
|
||||
gitpkgs = import /home/steveej/src/github/NixOS/nixpkgs {};
|
||||
unstablepkgs = import <nixos-unstable> {};
|
||||
|
||||
in
|
||||
{
|
||||
in {
|
||||
nixpkgs.config = {
|
||||
allowBroken = false;
|
||||
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
|
||||
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