refactor: move my modules to my NUR

refs: nekowinston/nur@aab9dadf5c
This commit is contained in:
winston 2023-06-04 02:31:13 +02:00
parent 47abbffb1b
commit c4339039cf
Signed by: winston
GPG key ID: 3786770EDBC2B481
7 changed files with 5 additions and 217 deletions

View file

@ -205,11 +205,11 @@
"wezterm-src": "wezterm-src"
},
"locked": {
"lastModified": 1685516712,
"narHash": "sha256-12jRUKFRCEFajGn+R8vRf/X5EwAMS7syjzh1Cgl0rS4=",
"lastModified": 1685838267,
"narHash": "sha256-FE7fhLMlLXbHaihSlUtlXrnhGf6vPMppH6qRw/Tm8uA=",
"owner": "nekowinston",
"repo": "nur",
"rev": "8d7582ca117274ec894d871001fff39125d54be4",
"rev": "aab9dadf5c687862907f516916592e4ffd5f23b0",
"type": "github"
},
"original": {

View file

@ -78,10 +78,10 @@
useUserPackages = true;
backupFileExtension = "backup";
sharedModules = [
./modules/hm
inputs.nix-index-database.hmModules.nix-index
inputs.sops.homeManagerModules.sops
inputs.caarlos0-nur.homeManagerModules.default
inputs.nekowinston-nur.homeManagerModules.default
];
users.${username}.imports = [./home];
extraSpecialArgs = {
@ -124,7 +124,7 @@
system = "aarch64-darwin";
modules = [
home-manager.darwinModules.home-manager
./modules/darwin
inputs.nekowinston-nur.darwinModules.default
./machines/common
./machines/sashimi
(commonHMConfig {
@ -133,35 +133,6 @@
];
};
};
homeConfigurations.winston = let
system = "aarch64-linux";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
username = "winston";
in
home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [
{
home.homeDirectory = "/home/winston";
home.username = "/home/winston";
nixpkgs.overlays = [overlays];
nixpkgs.config.allowUnfree = true;
}
./modules/hm
./home
inputs.nix-index-database.hmModules.nix-index
inputs.sops.homeManagerModules.sops
];
extraSpecialArgs = {
flakePath =
if pkgs.stdenv.isDarwin
then "/Users/${username}/.config/nixpkgs"
else "/home/${username}/.config/nixpkgs";
};
};
}
// inputs.flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};

View file

@ -1,3 +0,0 @@
{
imports = [./yabai.nix];
}

View file

@ -1,93 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.yabai;
toYabaiConfig = opts:
concatStringsSep "\n" (mapAttrsToList
(p: v: "yabai -m config ${p} ${toString v}")
opts);
configFile = pkgs.writeScript "yabairc" (
optionalString cfg.enableScriptingAddition ''
${cfg.package}/bin/yabai -m signal --add event=dock_did_restart action="sudo ${cfg.package}/bin/yabai --load-sa"
sudo ${cfg.package}/bin/yabai --load-sa
''
+ optionalString (cfg.config != {}) ("\n" + (toYabaiConfig cfg.config) + "\n")
+ optionalString (cfg.extraConfig != "") ("\n" + cfg.extraConfig + "\n")
);
in {
disabledModules = ["services/yabai"];
options.services.yabai = with types; {
enable = mkEnableOption "Whether to enable the yabai window manager.";
package = mkPackageOption pkgs "yabai" {};
logFile = mkOption {
type = types.str;
default = "";
example = "/var/tmp/yabai.log";
description = "Path where you want to write daemon logs.";
};
enableScriptingAddition = mkEnableOption ''
Whether to enable yabai's scripting-addition.
SIP must be disabled for this to work.
'';
config = mkOption {
type = attrs;
default = {};
example = literalExpression ''
{
focus_follows_mouse = "autoraise";
mouse_follows_focus = "off";
window_placement = "second_child";
window_opacity = "off";
top_padding = 36;
bottom_padding = 10;
left_padding = 10;
right_padding = 10;
window_gap = 10;
}
'';
description = ''
Key/Value pairs to pass to yabai's 'config' domain, via the configuration file.
'';
};
extraConfig = mkOption {
type = str;
default = "";
example = literalExpression ''
yabai -m rule --add app='System Preferences' manage=off
'';
description = "Extra arbitrary configuration to append to the configuration file";
};
};
config = mkMerge [
(mkIf cfg.enable {
environment.systemPackages = [cfg.package];
launchd.user.agents.yabai.serviceConfig = rec {
ProgramArguments = ["${cfg.package}/bin/yabai" "-c" "${configFile}"];
KeepAlive = true;
RunAtLoad = true;
EnvironmentVariables.PATH = "${cfg.package}/bin:${config.environment.systemPath}";
StandardOutPath = mkIf (cfg.logFile != "") "${cfg.logFile}";
StandardErrorPath = StandardOutPath;
};
})
(mkIf cfg.enableScriptingAddition {
environment.etc."sudoers.d/yabai".text = let
sha = builtins.hashFile "sha256" "${cfg.package}/bin/yabai";
in "%admin ALL=(root) NOPASSWD: sha256:${sha} ${cfg.package}/bin/yabai --load-sa";
})
];
}

View file

@ -1,82 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.darkman;
configModule = types.submodule ({config, ...}: {
options = {
lat = mkOption {
type = types.nullOr types.float;
default = null;
description = "Latitude to use for geoclue.";
};
lng = mkOption {
type = types.nullOr types.float;
default = null;
description = "Longitude to use for geoclue.";
};
useGeoclue = mkOption {
type = types.bool;
default = true;
description = "Whether to use a local geoclue instance to determine the current location. On some distributions/setups, this may require setting up a geoclue agent to function properly. The default for this will change to false in v2.0.";
};
useDbus = mkOption {
type = types.bool;
default = true;
description = "Whether to expose the current mode via darkman's own D-Bus API. The command line tool uses this API to apply changes, so it will not work if this setting is disabled. ";
};
portal = mkOption {
type = types.bool;
default = true;
description = "Whether to use the portal for communication.";
};
};
});
in {
options.services.darkman = {
enable = mkEnableOption "darkman";
package = mkPackageOption pkgs "darkman" {};
config = mkOption {
type = configModule;
default = {};
description = "Config for darkman.";
};
};
config = mkIf cfg.enable {
home.packages = [cfg.package];
systemd.user.services.darkman = {
Unit = {
Description = "Framework for dark-mode and light-mode transitions.";
Documentation = ["man:darkman(1)"];
};
Service = {
Type = "dbus";
BusName = "nl.whynothugo.darkman";
ExecStart = "${lib.getExe cfg.package} run";
Restart = "on-failure";
TimeoutStopSec = 15;
Slice = "background.slice";
# Security hardening
LockPersonality = "yes";
RestrictNamespaces = "yes";
SystemCallArchitectures = "native";
SystemCallFilter = "@system-service @timer mincore";
MemoryDenyWriteExecute = "yes";
};
Install = {
WantedBy = ["default.target"];
};
};
xdg.configFile."darkman/config.yaml".text = builtins.toJSON ({
inherit (cfg.config) useGeoclue useDbus portal;
}
// optionalAttrs (cfg.config.lat != null && cfg.config.lng != null) {
inherit (cfg.config) lat lng;
});
};
}

View file

@ -1,3 +0,0 @@
{
imports = [./darkman.nix];
}

View file

@ -1,2 +0,0 @@
{
}