Migrate hostname detection

Define it as variable instead of function.
Pass variable and do individual checks instead of function call.
This commit is contained in:
Daniel Siepmann 2024-05-29 09:54:20 +02:00
parent 1b05cfbc67
commit 4a6b4b8f1c
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
11 changed files with 31 additions and 34 deletions

View file

@ -6,7 +6,7 @@
}:
let
ownLib = import ./home/packages/lib;
hostName = builtins.replaceStrings ["\n"] [""] (builtins.readFile /etc/hostname);
in {
@ -39,13 +39,13 @@ in {
stateVersion = "22.05";
packages = import ./home/packages.nix {
inherit pkgs ownLib;
inherit pkgs hostName;
};
file = import ./home/files.nix { };
} // import ./home/home.nix {
inherit config pkgs ownLib;
inherit config pkgs hostName;
};
targets.genericLinux.enable = true;
@ -59,13 +59,13 @@ in {
};
programs = import ./home/programs.nix {
inherit config pkgs ownLib;
inherit config pkgs hostName;
};
fonts.fontconfig.enable = true;
xsession = import ./home/xsession.nix {
inherit config pkgs ownLib;
inherit config pkgs hostName;
};
xdg = import ./home/xdg.nix {
@ -84,7 +84,7 @@ in {
};
services = import ./home/services.nix {
inherit config ownLib pkgs;
inherit config hostName pkgs;
};
systemd.user = import ./home/systemd.nix {

View file

@ -1,7 +1,7 @@
{
config
,pkgs
,ownLib
,hostName
}:
let
@ -83,7 +83,7 @@ in {
TYPO3_CONTEXT = "Development/dsiepmann";
TYPO3_ADDITIONAL_CONFIGURATION = "${config.xdg.dataHome}/typo3-configuration/AdditionalConfiguration.inc.php";
} // (if ownLib.onHikari {} then {
} // (if hostName == "hikari" then {
} else {
});

View file

@ -1,6 +1,6 @@
{
pkgs
,ownLib
,hostName
}:
with pkgs; [
@ -79,7 +79,7 @@ with pkgs; [
unzip
gtk-engine-murrine
] ++ (if ownLib.onHikari {} then [
] ++ (if hostName == "hikari" then [
# hikari
acpilight # Used to support xbacklight
@ -97,5 +97,5 @@ with pkgs; [
(callPackage ./packages/custom/backup { })
(callPackage ./packages/custom/vpn-reuter-dynamics { })
]) ++ (callPackage ./packages/custom {
inherit ownLib;
inherit hostName;
})

View file

@ -1,6 +1,6 @@
{
callPackage
,ownLib
,hostName
}:
[
@ -14,6 +14,6 @@
(callPackage ./typo3-push-core { })
(callPackage ./zcat-progress { })
(callPackage ./project {
inherit ownLib;
inherit hostName;
})
]

View file

@ -2,13 +2,13 @@
writeShellApplication
,bash
,gnused
,ownLib
,hostName
}:
let
positionOfCustomerName = if ownLib.onHikari {} then "5" else "7";
mysqlUser = if ownLib.onHikari {} then "-u daniels" else "";
positionOfCustomerName = if hostName == "hikari" then "5" else "7";
mysqlUser = if hostName == "hikari" then "-u daniels" else "";
in writeShellApplication {
name = "custom-project";

View file

@ -1,3 +0,0 @@
{
onHikari = _: builtins.readFile(/etc/hostname) == "hikari\n";
}

View file

@ -1,7 +1,7 @@
{
config
,pkgs
,ownLib
,hostName
}:
let
@ -51,7 +51,7 @@ in {
};
firefox = import ./programs/firefox.nix {
inherit pkgs ownLib;
inherit pkgs hostName;
};
vdirsyncer.enable = true;

View file

@ -1,11 +1,11 @@
{
pkgs
,ownLib
,hostName
}:
let
devtoolsPosition = if ownLib.onHikari {} then "bottom" else "right";
devtoolsPosition = if hostName == "hikari" then "bottom" else "right";
in {
enable = true;

View file

@ -1,6 +1,6 @@
{
config
,ownLib
,hostName
,pkgs
}:
@ -22,7 +22,7 @@
languagetool.enable = true;
mailhog.enable = true;
} // (if ownLib.onHikari {} then {
} // (if hostName == "hikari" then {
network-manager-applet.enable = true;
} else {
})

View file

@ -1,7 +1,7 @@
{
config
,pkgs
,ownLib
,hostName
}:
# Use `xbindkeys --key` to find key name, see: https://wiki.archlinux.org/title/Xbindkeys
@ -10,11 +10,11 @@
let
modifier = config.xsession.windowManager.i3.config.modifier;
soundSwitcherForHikari2 = if ownLib.onHikari { } then "" else "-D pulse";
keyboardBrightnessDevice = if ownLib.onHikari { } then "--device smc::kbd_backlight" else "";
displayBrightnessDevice = if ownLib.onHikari { } then "--device acpi_video0" else "";
displayBuiltInOutput = if ownLib.onHikari { } then "eDP-1" else "eDP1";
displayDefaults = if ownLib.onHikari { } then "--output ${displayBuiltInOutput} --mode 1366x768 --scale 1.25x1.25" else "";
soundSwitcherForHikari2 = if hostName == "hikari" then "" else "-D pulse";
keyboardBrightnessDevice = if hostName == "hikari" then "--device smc::kbd_backlight" else "";
displayBrightnessDevice = if hostName == "hikari" then "--device acpi_video0" else "";
displayBuiltInOutput = if hostName == "hikari" then "eDP-1" else "eDP1";
displayDefaults = if hostName == "hikari" then "--output ${displayBuiltInOutput} --mode 1366x768 --scale 1.25x1.25" else "";
in {
enable = true;
config = {

View file

@ -1,7 +1,7 @@
{
config
,pkgs
,ownLib
,hostName
}:
let
@ -25,7 +25,7 @@ in {
numlock.enable = true;
initExtra = (if ownLib.onHikari {} then initExtraHikari else initExtraHikari2) + ''
initExtra = (if hostName == "hikari" then initExtraHikari else initExtraHikari2) + ''
# Set backlight of output
xbacklight -set 25
@ -40,6 +40,6 @@ in {
'';
windowManager.i3 = import ./windowManager/i3.nix {
inherit config pkgs ownLib;
inherit config pkgs hostName;
};
}