[nix] Messing around with how to override desktop files

This commit is contained in:
Drew Haven 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 =
{ 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 = {
altair = (import ./system/hosts/altair) {
inherit inputs;
inherit self;
nixpkgs = inputs.nixpkgs-unstable;
altair = mkNixosConfig {
path = ./system/hosts/altair;
};
mcp = (import ./system/hosts/mcp) {
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; [
# Gaming
@ -16,19 +28,21 @@
wowup-cf
];
xdg.desktopEntries = {
# wowup needs options to work under wayland.
wowup-cf = {
name = "WowUp";
# Custom options to reduce flickering under wayland.
exec = "wowup-cf --no-sandbox --enable-features=UseOzonePlatform --ozone-platform=wayland --disable-gpu %U";
terminal = false;
type = "Application";
icon = "wowup-cf";
comment = "World of Warcraft addon updater";
categories = [
"Game"
];
};
# xdg.dataFile."applications/wowup-cf.desktop" = {
# force = true;
# source = "${patched-desktop}/wowup-cf.desktop";
# };
# wowup needs options to work under wayland.
xdg.desktopEntries.wowup-cf = local.electronDesktopEntry {
name = "WowUp";
exec = "wowup-cf --no-sandbox";
terminal = false;
type = "Application";
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
./hardware-configuration.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}`))";
localHostRule = host: domain: "${localNetRule} && ${hostRule host domain}";
localHostRuleHavenisms = host: localHostRule host havenisms;
in
in
{
inherit
hostRule
@ -17,26 +17,35 @@ in
hostRuleHavenisms
localHostRuleHavenisms
havenisms
blazestar;
blazestar
;
mkContainer = {
image,
hostName,
port,
homepageOpts,
dependsOn ? [],
domain ? havenisms,
ports ? [],
volumes ? [],
environment ? {},
environmentFiles ? [],
public ? false,
}:
let routerRule = if public then hostRule hostName domain else localHostRule hostName domain;
mkContainer =
{
image,
hostName,
port,
homepageOpts,
dependsOn ? [ ],
domain ? havenisms,
ports ? [ ],
volumes ? [ ],
environment ? { },
environmentFiles ? [ ],
public ? false,
}:
let
routerRule = if public then hostRule hostName domain else localHostRule hostName domain;
in
{
inherit image dependsOn volumes environment environmentFiles ports;
inherit
image
dependsOn
volumes
environment
environmentFiles
ports
;
hostname = "${hostName}.${domain}";
autoStart = true;
extraOptions = [
@ -57,30 +66,33 @@ in
# user.
#
# Note that this returns a _module_ so that it can be imported and provide many different config values.
mkMariaDbContainer = {
name,
uid,
gid,
passwordSecret,
directory,
}: { config, ... }: {
virtualisation.oci-containers.containers."${name}-mariadb" = {
image = "lscr.io/linuxserver/mariadb:latest";
autoStart = true;
ports = [ "3306:3306" ];
volumes = [
"${directory}:/config"
"${config.sops.secrets.mariadb_root_password.path}:/run/secrets/mariadb_root_password"
"${config.sops.secrets."${passwordSecret}".path}:/run/secrets/mariadb_password"
];
environment = {
PUID = "${toString uid}";
PGID = "${toString gid}";
MYSQL_USER = name;
MYSQL_DATABASE = name;
FILE__MYSQL_ROOT_PASSWORD = "/run/secrets/mariadb_root_password";
FILE__MYSQL_PASSWORD = "/run/secrets/mariadb_password";
mkMariaDbContainer =
{
name,
uid,
gid,
passwordSecret,
directory,
}:
{ config, ... }:
{
virtualisation.oci-containers.containers."${name}-mariadb" = {
image = "lscr.io/linuxserver/mariadb:latest";
autoStart = true;
ports = [ "3306:3306" ];
volumes = [
"${directory}:/config"
"${config.sops.secrets.mariadb_root_password.path}:/run/secrets/mariadb_root_password"
"${config.sops.secrets."${passwordSecret}".path}:/run/secrets/mariadb_password"
];
environment = {
PUID = "${toString uid}";
PGID = "${toString gid}";
MYSQL_USER = name;
MYSQL_DATABASE = name;
FILE__MYSQL_ROOT_PASSWORD = "/run/secrets/mariadb_root_password";
FILE__MYSQL_PASSWORD = "/run/secrets/mariadb_password";
};
};
};
};
}