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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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