From 06d6cde03c8dddf8b89a5ab335a24c2f7ded441a Mon Sep 17 00:00:00 2001 From: Joel McCracken Date: Fri, 3 Nov 2023 20:38:33 -0400 Subject: [PATCH] optimizing how nix conf file is setup --- bootstrap-workstation.sh | 11 +++++++++-- lib/shell/setup/install_system_nix_conf.sh | 10 ++++++++-- workstation.org | 11 +++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/bootstrap-workstation.sh b/bootstrap-workstation.sh index 5048ce43..a4dbf0d5 100755 --- a/bootstrap-workstation.sh +++ b/bootstrap-workstation.sh @@ -187,8 +187,10 @@ function install_doom_emacs_no_nix() { # install_doom_emacs_no_nix_function ends here # [[file:workstation.org::install_system_nix_conf_function][install_system_nix_conf_function]] -function install_system_nix_conf() { - (sudo bash -c 'mkdir -p /etc/nix; cat > /etc/nix/nix.conf') <<-EOF + +function emit_nix_conf_content () { + cat - <<-EOF +# Generated at $(date) trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= substituters = https://cache.nixos.org https://cache.iog.io experimental-features = nix-command flakes @@ -197,6 +199,11 @@ build-users-group = nixbld # END OF /etc/nix/nix.conf EOF } + +function install_system_nix_conf() { + emit_nix_conf_content | \ + sudo bash -c 'mkdir -p /etc/nix; cat > /etc/nix/nix.conf' +} # install_system_nix_conf_function ends here # [[file:workstation.org::restart_nix_deamon_function][restart_nix_deamon_function]] diff --git a/lib/shell/setup/install_system_nix_conf.sh b/lib/shell/setup/install_system_nix_conf.sh index 048979d7..2b441b0d 100755 --- a/lib/shell/setup/install_system_nix_conf.sh +++ b/lib/shell/setup/install_system_nix_conf.sh @@ -3,8 +3,9 @@ # External Script: # [[file:../../../workstation.org::*install nix configuration file][install nix configuration file:2]] -function install_system_nix_conf() { - (sudo bash -c 'mkdir -p /etc/nix; cat > /etc/nix/nix.conf') <<-EOF +function emit_nix_conf_content () { + cat - <<-EOF +# Generated at $(date) trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= substituters = https://cache.nixos.org https://cache.iog.io experimental-features = nix-command flakes @@ -13,5 +14,10 @@ build-users-group = nixbld # END OF /etc/nix/nix.conf EOF } + +function install_system_nix_conf() { + emit_nix_conf_content | \ + sudo bash -c 'mkdir -p /etc/nix; cat > /etc/nix/nix.conf' +} install_system_nix_conf # install nix configuration file:2 ends here diff --git a/workstation.org b/workstation.org index ca8923e9..43373e74 100644 --- a/workstation.org +++ b/workstation.org @@ -584,8 +584,10 @@ complications. think its overall easier to just hack a thing with bash. #+name: install_system_nix_conf_function #+begin_src shell :noweb yes -function install_system_nix_conf() { - (sudo bash -c 'mkdir -p /etc/nix; cat > /etc/nix/nix.conf') <<-EOF + +function emit_nix_conf_content () { + cat - <<-EOF +# Generated at $(date) trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= substituters = https://cache.nixos.org https://cache.iog.io experimental-features = nix-command flakes @@ -594,6 +596,11 @@ build-users-group = nixbld # END OF /etc/nix/nix.conf EOF } + +function install_system_nix_conf() { + emit_nix_conf_content | \ + sudo bash -c 'mkdir -p /etc/nix; cat > /etc/nix/nix.conf' +} #+end_src External Script: #+begin_src sh :tangle ./lib/shell/setup/install_system_nix_conf.sh :shebang "#!/usr/bin/env bash" :noweb yes