From 04311f191f7af0d6c109e93b66f54b598e554ede Mon Sep 17 00:00:00 2001 From: wxlyyy <1556588440@qq.com> Date: Fri, 21 Nov 2025 02:22:57 +0800 Subject: [PATCH] Nix: cleaner code --- flake.lock | 18 +----------------- flake.nix | 22 +++++++--------------- nix/home-module.nix | 5 ++--- nix/nixos-module.nix | 12 ++---------- nix/package.nix | 1 - 5 files changed, 12 insertions(+), 46 deletions(-) diff --git a/flake.lock b/flake.lock index c425c56d..d4068481 100644 --- a/flake.lock +++ b/flake.lock @@ -18,23 +18,7 @@ }, "root": { "inputs": { - "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" + "nixpkgs": "nixpkgs" } } }, diff --git a/flake.nix b/flake.nix index e905544e..421f2221 100644 --- a/flake.nix +++ b/flake.nix @@ -3,24 +3,21 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - systems.url = "github:nix-systems/default"; }; outputs = { self, nixpkgs, - systems, ... }: 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 { - formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.alejandra); + formatter = eachSystem (system: pkgsFor.${system}.alejandra); packages = eachSystem ( - system: let - pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [self.overlays.default]; - in { - default = pkgs.noctalia-shell; + system: { + default = pkgsFor.${system}.noctalia-shell; } ); @@ -42,10 +39,8 @@ }; devShells = eachSystem ( - system: let - pkgs = nixpkgs.legacyPackages.${system}; - in { - default = pkgs.callPackage ./nix/shell.nix {}; + system: { + default = pkgsFor.${system}.callPackage ./nix/shell.nix {}; } ); @@ -58,9 +53,6 @@ programs.noctalia-shell.package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default; - programs.noctalia-shell.app2unit.package = - lib.mkDefault - nixpkgs.legacyPackages.${pkgs.stdenv.hostPlatform.system}.app2unit; }; nixosModules.default = { diff --git a/nix/home-module.nix b/nix/home-module.nix index 6126c268..785317cd 100644 --- a/nix/home-module.nix +++ b/nix/home-module.nix @@ -89,6 +89,7 @@ in { app2unit.package = lib.mkOption { type = lib.types.package; + default = pkgs.app2unit; description = '' The app2unit package to use when appLauncher.useApp2Unit is enabled. ''; @@ -96,9 +97,7 @@ in { }; config = let - restart = '' - ${pkgs.systemd}/bin/systemctl --user try-restart noctalia-shell.service 2>/dev/null || true - ''; + restart = "${pkgs.systemd}/bin/systemctl --user try-restart noctalia-shell.service 2>/dev/null || true"; useApp2Unit = cfg.settings.appLauncher.useApp2Unit or false; in lib.mkIf cfg.enable { diff --git a/nix/nixos-module.nix b/nix/nixos-module.nix index bbab247c..124acb11 100644 --- a/nix/nixos-module.nix +++ b/nix/nixos-module.nix @@ -24,7 +24,7 @@ in { config = lib.mkIf cfg.enable { systemd.user.services.noctalia-shell = { description = "Noctalia Shell - Wayland desktop shell"; - documentation = ["https://github.com/noctalia-dev/noctalia-shell"]; + documentation = ["https://docs.noctalia.dev/docs"]; after = [cfg.target]; partOf = [cfg.target]; wantedBy = [cfg.target]; @@ -34,17 +34,9 @@ in { PATH = lib.mkForce null; }; - unitConfig = { - StartLimitIntervalSec = 60; - StartLimitBurst = 3; - }; - serviceConfig = { - ExecStart = "${cfg.package}/bin/noctalia-shell"; + ExecStart = lib.getExe cfg.package; Restart = "on-failure"; - RestartSec = 3; - TimeoutStartSec = 10; - TimeoutStopSec = 5; Environment = [ "NOCTALIA_SETTINGS_FALLBACK=%h/.config/noctalia/gui-settings.json" ]; diff --git a/nix/package.nix b/nix/package.nix index cacec580..66b1e6c5 100644 --- a/nix/package.nix +++ b/nix/package.nix @@ -26,7 +26,6 @@ /.github /.gitignore /Assets/Screenshots - /Assets/Wallpaper /Bin/dev /nix /LICENSE