[nix] Messing around with how to override desktop files

This commit is contained in:
2025-04-17 20:03:18 -07:00
parent 828aaa5d40
commit c2a5e0a709
6 changed files with 138 additions and 84 deletions

View File

@@ -32,12 +32,36 @@
outputs = outputs =
{ self, nixpkgs, ... }@inputs: { self, nixpkgs, ... }@inputs:
let
local = import ./lib;
mkNixosConfig =
{
path,
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs-unstable,
}:
nixpkgs.lib.nixosSystem {
inherit system;
modules = [
inputs.home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs local;
};
}
path
];
specialArgs = {
inherit inputs local;
};
};
in
{ {
nixosConfigurations = { nixosConfigurations = {
altair = (import ./system/hosts/altair) { altair = mkNixosConfig {
inherit inputs; path = ./system/hosts/altair;
inherit self;
nixpkgs = inputs.nixpkgs-unstable;
}; };
mcp = (import ./system/hosts/mcp) { mcp = (import ./system/hosts/mcp) {
inherit inputs; inherit inputs;

View File

@@ -1,4 +1,16 @@
{ pkgs, ... }: { pkgs, local, ... }:
# let
# patched-desktop =
# pkgs.runCommand "patched-wowup-cf-desktop"
# {
# desktop = "${pkgs.wowup-cf}/share/applications/wowup-cf.desktop";
# }
# ''
# mkdir -p $out
# substitute "$desktop" "$out/wowup-cf.desktop" \
# --replace-fail 'Exec=wowup-cf' 'Exec=wowup-cf --enable-features=UseOzonePlatform --ozone-platform=wayland --disable-gpu'
# '';
# in
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
# Gaming # Gaming
@@ -16,19 +28,21 @@
wowup-cf wowup-cf
]; ];
xdg.desktopEntries = { # xdg.dataFile."applications/wowup-cf.desktop" = {
# wowup needs options to work under wayland. # force = true;
wowup-cf = { # source = "${patched-desktop}/wowup-cf.desktop";
name = "WowUp"; # };
# Custom options to reduce flickering under wayland.
exec = "wowup-cf --no-sandbox --enable-features=UseOzonePlatform --ozone-platform=wayland --disable-gpu %U"; # wowup needs options to work under wayland.
terminal = false; xdg.desktopEntries.wowup-cf = local.electronDesktopEntry {
type = "Application"; name = "WowUp";
icon = "wowup-cf"; exec = "wowup-cf --no-sandbox";
comment = "World of Warcraft addon updater"; terminal = false;
categories = [ type = "Application";
"Game" icon = "wowup-cf";
]; comment = "World of Warcraft addon updater";
}; categories = [
"Game"
];
}; };
} }

3
lib/default.nix Normal file
View File

@@ -0,0 +1,3 @@
{
inherit (import ./electron.nix) electronDesktopEntry;
}

9
lib/electron.nix Normal file
View File

@@ -0,0 +1,9 @@
{
# Adds extra arguments to avoid flickering under wayland.
electronDesktopEntry =
desktop:
desktop
// {
exec = "${desktop.exec} --enable-features=UseOzonePlatform --ozone-platform=wayland --disable-gpu";
};
}

View File

@@ -1,28 +1,20 @@
{ nixpkgs, inputs, ... }: {
nixpkgs.lib.nixosSystem { ...
system = "x86_64-linux"; }:
modules = [ {
imports = [
./configuration.nix ./configuration.nix
./hardware-configuration.nix ./hardware-configuration.nix
../../authorized-keys.nix ../../authorized-keys.nix
inputs.home-manager.nixosModules.home-manager
{
nixpkgs.config.allowUnfree = true;
home-manager.users.drew =
{ ... }:
{
imports = [
./drew.nix
];
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit inputs;
};
}
]; ];
specialArgs = {
inherit inputs; nixpkgs.config.allowUnfree = true;
};
home-manager.users.drew =
{ ... }:
{
imports = [
./drew.nix
];
};
} }

View File

@@ -9,7 +9,7 @@ let
localNetRule = "(ClientIP(`${localNet}`) || ClientIP(`${dockerNet}`))"; localNetRule = "(ClientIP(`${localNet}`) || ClientIP(`${dockerNet}`))";
localHostRule = host: domain: "${localNetRule} && ${hostRule host domain}"; localHostRule = host: domain: "${localNetRule} && ${hostRule host domain}";
localHostRuleHavenisms = host: localHostRule host havenisms; localHostRuleHavenisms = host: localHostRule host havenisms;
in in
{ {
inherit inherit
hostRule hostRule
@@ -17,26 +17,35 @@ in
hostRuleHavenisms hostRuleHavenisms
localHostRuleHavenisms localHostRuleHavenisms
havenisms havenisms
blazestar; blazestar
;
mkContainer =
mkContainer = { {
image, image,
hostName, hostName,
port, port,
homepageOpts, homepageOpts,
dependsOn ? [], dependsOn ? [ ],
domain ? havenisms, domain ? havenisms,
ports ? [], ports ? [ ],
volumes ? [], volumes ? [ ],
environment ? {}, environment ? { },
environmentFiles ? [], environmentFiles ? [ ],
public ? false, public ? false,
}: }:
let routerRule = if public then hostRule hostName domain else localHostRule hostName domain; let
routerRule = if public then hostRule hostName domain else localHostRule hostName domain;
in in
{ {
inherit image dependsOn volumes environment environmentFiles ports; inherit
image
dependsOn
volumes
environment
environmentFiles
ports
;
hostname = "${hostName}.${domain}"; hostname = "${hostName}.${domain}";
autoStart = true; autoStart = true;
extraOptions = [ extraOptions = [
@@ -57,30 +66,33 @@ in
# user. # user.
# #
# Note that this returns a _module_ so that it can be imported and provide many different config values. # Note that this returns a _module_ so that it can be imported and provide many different config values.
mkMariaDbContainer = { mkMariaDbContainer =
name, {
uid, name,
gid, uid,
passwordSecret, gid,
directory, passwordSecret,
}: { config, ... }: { directory,
virtualisation.oci-containers.containers."${name}-mariadb" = { }:
image = "lscr.io/linuxserver/mariadb:latest"; { config, ... }:
autoStart = true; {
ports = [ "3306:3306" ]; virtualisation.oci-containers.containers."${name}-mariadb" = {
volumes = [ image = "lscr.io/linuxserver/mariadb:latest";
"${directory}:/config" autoStart = true;
"${config.sops.secrets.mariadb_root_password.path}:/run/secrets/mariadb_root_password" ports = [ "3306:3306" ];
"${config.sops.secrets."${passwordSecret}".path}:/run/secrets/mariadb_password" volumes = [
]; "${directory}:/config"
environment = { "${config.sops.secrets.mariadb_root_password.path}:/run/secrets/mariadb_root_password"
PUID = "${toString uid}"; "${config.sops.secrets."${passwordSecret}".path}:/run/secrets/mariadb_password"
PGID = "${toString gid}"; ];
MYSQL_USER = name; environment = {
MYSQL_DATABASE = name; PUID = "${toString uid}";
FILE__MYSQL_ROOT_PASSWORD = "/run/secrets/mariadb_root_password"; PGID = "${toString gid}";
FILE__MYSQL_PASSWORD = "/run/secrets/mariadb_password"; MYSQL_USER = name;
MYSQL_DATABASE = name;
FILE__MYSQL_ROOT_PASSWORD = "/run/secrets/mariadb_root_password";
FILE__MYSQL_PASSWORD = "/run/secrets/mariadb_password";
};
}; };
}; };
};
} }