From 995714ced3940fd75f74459744c73cbb661250af Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Tue, 14 Nov 2023 13:43:01 +0100 Subject: [PATCH] make evremap DRYer --- hosts/catbook-j/configuration.nix | 29 ++----------------- hosts/potatobook-g/configuration.nix | 25 +--------------- modules/desktop/default.nix | 1 + modules/desktop/evremap.nix | 25 ++++++++++++++++ ...aps-catbook.toml => remaps-catbook-j.toml} | 0 .../{remaps.toml => remaps-potatobook-g.toml} | 0 6 files changed, 29 insertions(+), 51 deletions(-) create mode 100644 modules/desktop/evremap.nix rename other/{remaps-catbook.toml => remaps-catbook-j.toml} (100%) rename other/{remaps.toml => remaps-potatobook-g.toml} (100%) diff --git a/hosts/catbook-j/configuration.nix b/hosts/catbook-j/configuration.nix index 14a50e2..35fd1e6 100644 --- a/hosts/catbook-j/configuration.nix +++ b/hosts/catbook-j/configuration.nix @@ -2,26 +2,7 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, lib, ... }: -let - evremap = pkgs.rustPlatform.buildRustPackage { - pname = "evremap"; - version = "0.1.0"; - src = pkgs.fetchFromGitHub { - owner = "wez"; - repo = "evremap"; - rev = "4480c4eda223b98899b0fbd926bc34f7bd0e1a18"; - sha256 = "sha256-BxSrphgW1n465FX6bKVkq6O0XE2JqanfSYlsGwWUWkQ="; - }; - cargoHash = ""; - cargoLock.lockFile = ../../other/evremap.Cargo.lock; - postPatch = '' - cp ${../../other/evremap.Cargo.lock} Cargo.lock - ''; - nativeBuildInputs = [ pkgs.pkg-config ]; - buildInputs = [ pkgs.libevdev ]; - }; -in { +{ config, pkgs, lib, ... }: { imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix @@ -77,13 +58,6 @@ in { "/crypto_keyfile.bin" = null; }; - systemd.services = { - evremap = { - script = "${evremap}/bin/evremap remap ${../../other/remaps-catbook.toml}"; - wantedBy = ["multi-user.target"]; - }; - }; - # nixpkgs = { # overlays = [ # (self: super: { @@ -136,6 +110,7 @@ in { LC_TELEPHONE = "de_DE.UTF-8"; LC_TIME = "de_DE.UTF-8"; }; + # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions # on your system were taken. It‘s perfectly fine and recommended to leave diff --git a/hosts/potatobook-g/configuration.nix b/hosts/potatobook-g/configuration.nix index 4bdf4b3..8925823 100644 --- a/hosts/potatobook-g/configuration.nix +++ b/hosts/potatobook-g/configuration.nix @@ -1,23 +1,4 @@ -{ pkgs, ... }: -let - evremap = pkgs.rustPlatform.buildRustPackage { - pname = "evremap"; - version = "0.1.0"; - src = pkgs.fetchFromGitHub { - owner = "wez"; - repo = "evremap"; - rev = "4480c4eda223b98899b0fbd926bc34f7bd0e1a18"; - sha256 = "sha256-BxSrphgW1n465FX6bKVkq6O0XE2JqanfSYlsGwWUWkQ="; - }; - cargoHash = ""; - cargoLock.lockFile = ../../other/evremap.Cargo.lock; - postPatch = '' - cp ${../../other/evremap.Cargo.lock} Cargo.lock - ''; - nativeBuildInputs = [ pkgs.pkg-config ]; - buildInputs = [ pkgs.libevdev ]; - }; -in { +{ pkgs, ... }: { nix.settings = { trusted-substituters = [ "https://t2linux.cachix.org" @@ -185,10 +166,6 @@ in { fi ''; }; - evremap = { - script = "${evremap}/bin/evremap remap ${../../other/remaps.toml}"; - wantedBy = ["multi-user.target"]; - }; }; services.logind.extraConfig = '' diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index ee31ec1..b508479 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -26,6 +26,7 @@ in with lib; { ./social.nix ./mail.nix ./specific-hardware + ./evremap.nix ./xmonad.nix ]; diff --git a/modules/desktop/evremap.nix b/modules/desktop/evremap.nix new file mode 100644 index 0000000..183647c --- /dev/null +++ b/modules/desktop/evremap.nix @@ -0,0 +1,25 @@ +{ pkgs, config, ... }: +let + evremap = pkgs.rustPlatform.buildRustPackage { + pname = "evremap"; + version = "0.1.0"; + src = pkgs.fetchFromGitHub { + owner = "wez"; + repo = "evremap"; + rev = "4480c4eda223b98899b0fbd926bc34f7bd0e1a18"; + sha256 = "sha256-BxSrphgW1n465FX6bKVkq6O0XE2JqanfSYlsGwWUWkQ="; + }; + cargoHash = ""; + cargoLock.lockFile = ../../other/evremap.Cargo.lock; + postPatch = '' + cp ${../../other/evremap.Cargo.lock} Cargo.lock + ''; + nativeBuildInputs = [ pkgs.pkg-config ]; + buildInputs = [ pkgs.libevdev ]; + }; +in { + systemd.services.evremap = { + script = "${evremap}/bin/evremap remap ${../../other/remaps-${config.networking.hostName}.toml}"; + wantedBy = [ "multi-user.target" ]; + }; +} diff --git a/other/remaps-catbook.toml b/other/remaps-catbook-j.toml similarity index 100% rename from other/remaps-catbook.toml rename to other/remaps-catbook-j.toml diff --git a/other/remaps.toml b/other/remaps-potatobook-g.toml similarity index 100% rename from other/remaps.toml rename to other/remaps-potatobook-g.toml