Skip to content

Commit

Permalink
optimizing how nix conf file is setup
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmccracken committed Nov 4, 2023
1 parent 22ed04d commit 06d6cde
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
11 changes: 9 additions & 2 deletions bootstrap-workstation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]]
Expand Down
10 changes: 8 additions & 2 deletions lib/shell/setup/install_system_nix_conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
11 changes: 9 additions & 2 deletions workstation.org
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 06d6cde

Please sign in to comment.