Nix: cleaner code

This commit is contained in:
wxlyyy
2025-11-21 02:22:57 +08:00
parent e9114297d1
commit 04311f191f
5 changed files with 12 additions and 46 deletions

18
flake.lock generated
View File

@@ -18,23 +18,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"systems": "systems"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
} }
} }
}, },

View File

@@ -3,24 +3,21 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default";
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
systems,
... ...
}: let }: let
eachSystem = nixpkgs.lib.genAttrs (import systems); eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
pkgsFor = eachSystem (system: nixpkgs.legacyPackages.${system}.appendOverlays [self.overlays.default]);
in { in {
formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra); formatter = eachSystem (system: pkgsFor.${system}.alejandra);
packages = eachSystem ( packages = eachSystem (
system: let system: {
pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [self.overlays.default]; default = pkgsFor.${system}.noctalia-shell;
in {
default = pkgs.noctalia-shell;
} }
); );
@@ -42,10 +39,8 @@
}; };
devShells = eachSystem ( devShells = eachSystem (
system: let system: {
pkgs = nixpkgs.legacyPackages.${system}; default = pkgsFor.${system}.callPackage ./nix/shell.nix {};
in {
default = pkgs.callPackage ./nix/shell.nix {};
} }
); );
@@ -58,9 +53,6 @@
programs.noctalia-shell.package = programs.noctalia-shell.package =
lib.mkDefault lib.mkDefault
self.packages.${pkgs.stdenv.hostPlatform.system}.default; self.packages.${pkgs.stdenv.hostPlatform.system}.default;
programs.noctalia-shell.app2unit.package =
lib.mkDefault
nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}.app2unit;
}; };
nixosModules.default = { nixosModules.default = {

View File

@@ -89,6 +89,7 @@ in {
app2unit.package = lib.mkOption { app2unit.package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.app2unit;
description = '' description = ''
The app2unit package to use when appLauncher.useApp2Unit is enabled. The app2unit package to use when appLauncher.useApp2Unit is enabled.
''; '';
@@ -96,9 +97,7 @@ in {
}; };
config = let config = let
restart = '' restart = "${pkgs.systemd}/bin/systemctl --user try-restart noctalia-shell.service 2>/dev/null || true";
${pkgs.systemd}/bin/systemctl --user try-restart noctalia-shell.service 2>/dev/null || true
'';
useApp2Unit = cfg.settings.appLauncher.useApp2Unit or false; useApp2Unit = cfg.settings.appLauncher.useApp2Unit or false;
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {

View File

@@ -24,7 +24,7 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.user.services.noctalia-shell = { systemd.user.services.noctalia-shell = {
description = "Noctalia Shell - Wayland desktop shell"; description = "Noctalia Shell - Wayland desktop shell";
documentation = ["https://github.com/noctalia-dev/noctalia-shell"]; documentation = ["https://docs.noctalia.dev/docs"];
after = [cfg.target]; after = [cfg.target];
partOf = [cfg.target]; partOf = [cfg.target];
wantedBy = [cfg.target]; wantedBy = [cfg.target];
@@ -34,17 +34,9 @@ in {
PATH = lib.mkForce null; PATH = lib.mkForce null;
}; };
unitConfig = {
StartLimitIntervalSec = 60;
StartLimitBurst = 3;
};
serviceConfig = { serviceConfig = {
ExecStart = "${cfg.package}/bin/noctalia-shell"; ExecStart = lib.getExe cfg.package;
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 3;
TimeoutStartSec = 10;
TimeoutStopSec = 5;
Environment = [ Environment = [
"NOCTALIA_SETTINGS_FALLBACK=%h/.config/noctalia/gui-settings.json" "NOCTALIA_SETTINGS_FALLBACK=%h/.config/noctalia/gui-settings.json"
]; ];

View File

@@ -26,7 +26,6 @@
/.github /.github
/.gitignore /.gitignore
/Assets/Screenshots /Assets/Screenshots
/Assets/Wallpaper
/Bin/dev /Bin/dev
/nix /nix
/LICENSE /LICENSE