mirror of
https://github.com/elitak/nixos-infect
synced 2024-11-10 05:54:20 +00:00
random fixes (#63)
* use the nameservers That variable was being set, but not used * fix shellcheck issues
This commit is contained in:
parent
928f9e5e1d
commit
f42e554a40
1 changed files with 16 additions and 8 deletions
24
nixos-infect
24
nixos-infect
|
@ -18,7 +18,7 @@ makeConf() {
|
||||||
done
|
done
|
||||||
local network_import=""
|
local network_import=""
|
||||||
|
|
||||||
[ ! -z "$doNetConf" ] && network_import="./networking.nix # generated at runtime by nixos-infect"
|
[[ -n "$doNetConf" ]] && network_import="./networking.nix # generated at runtime by nixos-infect"
|
||||||
cat > /etc/nixos/configuration.nix << EOF
|
cat > /etc/nixos/configuration.nix << EOF
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -46,7 +46,7 @@ EOF
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ ! -z "$doNetConf" ]
|
if [[ -n "$doNetConf" ]]
|
||||||
then
|
then
|
||||||
makeNetworkingConf
|
makeNetworkingConf
|
||||||
else
|
else
|
||||||
|
@ -84,8 +84,12 @@ EOF
|
||||||
extraRules1=""
|
extraRules1=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
nameservers=($(grep ^nameserver /etc/resolv.conf | cut -f2 -d' '))
|
nameservers=()
|
||||||
if [ "$eth0_name" = eth* ]; then
|
while IFS='' read -r line; do
|
||||||
|
nameservers+=("$line")
|
||||||
|
done < <(grep ^nameserver /etc/resolv.conf | cut -f2 -d' ')
|
||||||
|
|
||||||
|
if [[ "$eth0_name" = eth* ]]; then
|
||||||
predictable_inames="usePredictableInterfaceNames = lib.mkForce false;"
|
predictable_inames="usePredictableInterfaceNames = lib.mkForce false;"
|
||||||
else
|
else
|
||||||
predictable_inames="usePredictableInterfaceNames = lib.mkForce true;"
|
predictable_inames="usePredictableInterfaceNames = lib.mkForce true;"
|
||||||
|
@ -95,7 +99,9 @@ EOF
|
||||||
# This file was populated at runtime with the networking
|
# This file was populated at runtime with the networking
|
||||||
# details gathered from the active system.
|
# details gathered from the active system.
|
||||||
networking = {
|
networking = {
|
||||||
nameservers = [ "8.8.8.8" ];
|
nameservers = [$(for a in "${nameservers[@]}"; do echo -n "
|
||||||
|
$a"; done)
|
||||||
|
];
|
||||||
defaultGateway = "${gateway}";
|
defaultGateway = "${gateway}";
|
||||||
defaultGateway6 = "${gateway6}";
|
defaultGateway6 = "${gateway6}";
|
||||||
dhcpcd.enable = false;
|
dhcpcd.enable = false;
|
||||||
|
@ -145,8 +151,8 @@ makeSwap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
removeSwap() {
|
removeSwap() {
|
||||||
swapoff -a
|
swapoff -a
|
||||||
rm -vf /tmp/nixos-infect.*.swp
|
rm -vf /tmp/nixos-infect.*.swp
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareEnv() {
|
prepareEnv() {
|
||||||
|
@ -225,7 +231,9 @@ infect() {
|
||||||
# Add nix build users
|
# Add nix build users
|
||||||
# FIXME run only if necessary, rather than defaulting true
|
# FIXME run only if necessary, rather than defaulting true
|
||||||
groupadd nixbld -g 30000 || true
|
groupadd nixbld -g 30000 || true
|
||||||
for i in {1..10}; do useradd -c "Nix build user $i" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(which nologin)" nixbld$i || true; done
|
for i in {1..10}; do
|
||||||
|
useradd -c "Nix build user $i" -d /var/empty -g nixbld -G nixbld -M -N -r -s "$(which nologin)" "nixbld$i" || true
|
||||||
|
done
|
||||||
# TODO use addgroup and adduser as fallbacks
|
# TODO use addgroup and adduser as fallbacks
|
||||||
#addgroup nixbld -g 30000 || true
|
#addgroup nixbld -g 30000 || true
|
||||||
#for i in {1..10}; do adduser -DH -G nixbld nixbld$i || true; done
|
#for i in {1..10}; do adduser -DH -G nixbld nixbld$i || true; done
|
||||||
|
|
Loading…
Reference in a new issue