From 7c0f8cf1b036b08e842f7c9ffbac6fb2e1931762 Mon Sep 17 00:00:00 2001 From: oli Date: Fri, 1 Nov 2024 18:33:05 +0000 Subject: [PATCH] nix: set formatter to nixfmt-rfc-style --- flake.nix | 321 +++++++++++++++++++++++++----------------------- src/default.nix | 69 ++++++----- 2 files changed, 204 insertions(+), 186 deletions(-) diff --git a/flake.nix b/flake.nix index 1457cb6f..87a509c3 100644 --- a/flake.nix +++ b/flake.nix @@ -7,177 +7,192 @@ }; }; - outputs = { - self, - nixpkgs, - astal, - }: let - system = "x86_64-linux"; - pkgs = import nixpkgs {inherit system;}; - in { - packages.${system} = - astal.packages.${system} - // { + outputs = + { + self, + nixpkgs, + astal, + }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + in + { + packages.${system} = astal.packages.${system} // { default = self.packages.${system}.ags; - ags = pkgs.callPackage ./src (with astal.packages.${system}; { - astal3 = astal3; - astal-io = io; - astal-gjs = "${gjs}/share/astal/gjs"; - }); - agsFull = pkgs.callPackage ./src (with astal.packages.${system}; { - astal3 = astal3; - astal-io = io; - astal-gjs = "${gjs}/share/astal/gjs"; - extraPackages = builtins.attrValues ( - builtins.removeAttrs astal.packages.${system} ["docs"] - ); - }); + ags = pkgs.callPackage ./src ( + with astal.packages.${system}; + { + astal3 = astal3; + astal-io = io; + astal-gjs = "${gjs}/share/astal/gjs"; + } + ); + agsFull = pkgs.callPackage ./src ( + with astal.packages.${system}; + { + astal3 = astal3; + astal-io = io; + astal-gjs = "${gjs}/share/astal/gjs"; + extraPackages = builtins.attrValues (builtins.removeAttrs astal.packages.${system} [ "docs" ]); + } + ); }; - devShells.${system} = { - default = astal.devShells.${system}.default.overrideAttrs (_: prev: { - buildInputs = prev.buildInputs ++ [pkgs.go]; - }); - }; - - homeManagerModules.default = { - config, - pkgs, - lib, - ... - }: let - inherit (lib) mkMerge types; - inherit (lib.modules) mkIf; - inherit (lib.options) mkOption mkEnableOption literalExpression; - - cfg = config.programs.ags; - default = { - agsPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default; - gtk3Package = self.packages.${pkgs.stdenv.hostPlatform.system}.astal3; - ioPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.io; - gjsPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.gjs; + devShells.${system} = { + default = astal.devShells.${system}.default.overrideAttrs ( + _: prev: { + buildInputs = prev.buildInputs ++ [ pkgs.go ]; + } + ); }; - in { - options.programs.ags = { - enable = mkEnableOption "ags"; - - package = mkOption { - type = types.package; - default = default.agsPackage; - defaultText = literalExpression "inputs.ags.packages.${pkgs.stdenv.hostPlatform.system}.default"; - description = '' - The Ags package to use. - - By default, this option will use the `packages.default` as exposed by this flake. - ''; - }; - - astal.gtk3Package = mkOption { - type = types.package; - default = default.gtk3Package; - defaultText = literalExpression "inputs.ags.packages.${pkgs.stdenv.hostPlatform.system}.astal3"; - description = '' - The GTK3 Astal package to use. - - By default, this option will use the `packages.astal3` as exposed by this flake. - ''; - }; - astal.ioPackage = mkOption { - type = types.package; - default = default.ioPackage; - defaultText = literalExpression "inputs.ags.packages.${pkgs.stdenv.hostPlatform.system}.io"; - description = '' - The core Astal package to use. + formatter.${system} = pkgs.nixfmt-rfc-style; + + homeManagerModules.default = + { + config, + pkgs, + lib, + ... + }: + let + inherit (lib) mkMerge types; + inherit (lib.modules) mkIf; + inherit (lib.options) mkOption mkEnableOption literalExpression; + + cfg = config.programs.ags; + default = { + agsPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default; + gtk3Package = self.packages.${pkgs.stdenv.hostPlatform.system}.astal3; + ioPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.io; + gjsPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.gjs; + }; + in + { + options.programs.ags = { + enable = mkEnableOption "ags"; + + package = mkOption { + type = types.package; + default = default.agsPackage; + defaultText = literalExpression "inputs.ags.packages.${pkgs.stdenv.hostPlatform.system}.default"; + description = '' + The Ags package to use. + + By default, this option will use the `packages.default` as exposed by this flake. + ''; + }; - By default, this option will use the `packages.io` as exposed by this flake. - ''; - }; + astal.gtk3Package = mkOption { + type = types.package; + default = default.gtk3Package; + defaultText = literalExpression "inputs.ags.packages.${pkgs.stdenv.hostPlatform.system}.astal3"; + description = '' + The GTK3 Astal package to use. - astal.gjsPackage = mkOption { - type = types.package; - default = default.gjsPackage; - description = '' - The Astal Gjs package to use. + By default, this option will use the `packages.astal3` as exposed by this flake. + ''; + }; - By default, this option will use the `packages.gjs` as exposed by this flake. - ''; - }; + astal.ioPackage = mkOption { + type = types.package; + default = default.ioPackage; + defaultText = literalExpression "inputs.ags.packages.${pkgs.stdenv.hostPlatform.system}.io"; + description = '' + The core Astal package to use. - finalPackage = mkOption { - type = types.package; - readOnly = true; - visible = false; - description = '' - Resulting ags package. - ''; - }; + By default, this option will use the `packages.io` as exposed by this flake. + ''; + }; - configDir = mkOption { - type = with types; nullOr path; - default = null; - example = literalExpression "./ags-config"; - description = '' - The directory to symlink to {file}`$XDG_CONFIG_HOME/ags`. - ''; - }; + astal.gjsPackage = mkOption { + type = types.package; + default = default.gjsPackage; + description = '' + The Astal Gjs package to use. - extraPackages = mkOption { - type = with types; listOf package; - default = []; - description = '' - Additional packages to add to gjs's runtime. - ''; - example = literalExpression "[ pkgs.libsoup_3 ]"; - }; + By default, this option will use the `packages.gjs` as exposed by this flake. + ''; + }; - systemd.enable = mkOption { - type = types.bool; - default = false; - example = true; - description = '' - Enable systemd integration. - ''; - }; - }; + finalPackage = mkOption { + type = types.package; + readOnly = true; + visible = false; + description = '' + Resulting ags package. + ''; + }; - config = mkIf cfg.enable (mkMerge [ - (mkIf (cfg.configDir != null) { - xdg.configFile."ags".source = cfg.configDir; - }) - (let - pkg = cfg.package.override { - extraPackages = cfg.extraPackages; - astal3 = cfg.astal.gtk3Package; - astal-io = cfg.astal.ioPackage; - astal-gjs = "${config.home.homeDirectory}/.local/share/ags"; - }; - in { - programs.ags.finalPackage = pkg; - home.packages = [pkg]; - home.file.".local/share/ags".source = "${cfg.astal.gjsPackage}/share/astal/gjs"; - }) - (mkIf cfg.systemd.enable { - systemd.user.services.ags = { - Unit = { - Description = "AGS - Tool for scaffolding Astal+TypeScript+JSX projects."; - Documentation = "https://github.com/Aylur/ags"; - PartOf = ["graphical-session.target"]; - After = ["graphical-session-pre.target"]; + configDir = mkOption { + type = with types; nullOr path; + default = null; + example = literalExpression "./ags-config"; + description = '' + The directory to symlink to {file}`$XDG_CONFIG_HOME/ags`. + ''; }; - Service = { - ExecStart = "${cfg.finalPackage}/bin/ags"; - Restart = "on-failure"; - KillMode = "mixed"; + extraPackages = mkOption { + type = with types; listOf package; + default = [ ]; + description = '' + Additional packages to add to gjs's runtime. + ''; + example = literalExpression "[ pkgs.libsoup_3 ]"; }; - Install = { - WantedBy = ["graphical-session.target"]; + systemd.enable = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Enable systemd integration. + ''; }; }; - }) - ]); + + config = mkIf cfg.enable (mkMerge [ + (mkIf (cfg.configDir != null) { + xdg.configFile."ags".source = cfg.configDir; + }) + ( + let + pkg = cfg.package.override { + extraPackages = cfg.extraPackages; + astal3 = cfg.astal.gtk3Package; + astal-io = cfg.astal.ioPackage; + astal-gjs = "${config.home.homeDirectory}/.local/share/ags"; + }; + in + { + programs.ags.finalPackage = pkg; + home.packages = [ pkg ]; + home.file.".local/share/ags".source = "${cfg.astal.gjsPackage}/share/astal/gjs"; + } + ) + (mkIf cfg.systemd.enable { + systemd.user.services.ags = { + Unit = { + Description = "AGS - Tool for scaffolding Astal+TypeScript+JSX projects."; + Documentation = "https://github.com/Aylur/ags"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + + Service = { + ExecStart = "${cfg.finalPackage}/bin/ags"; + Restart = "on-failure"; + KillMode = "mixed"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }) + ]); + }; }; - }; } diff --git a/src/default.nix b/src/default.nix index 3af00484..5d2bced0 100644 --- a/src/default.nix +++ b/src/default.nix @@ -12,16 +12,19 @@ gjs, nodejs, dart-sass, - extraPackages ? [], -}: let + extraPackages ? [ ], +}: +let inherit (builtins) replaceStrings readFile; - datadirs = writers.writeNu "datadirs" /*nu*/ '' - $env.XDG_DATA_DIRS - | split row ":" - | filter { $"($in)/gir-1.0" | path exists } - | str join ":" - ''; + datadirs = + writers.writeNu "datadirs" # nu + '' + $env.XDG_DATA_DIRS + | split row ":" + | filter { $"($in)/gir-1.0" | path exists } + | str join ":" + ''; bins = [ gjs @@ -30,33 +33,33 @@ astal-io # FIXME: should not be needed after the astal commends are properly implemented using dbus in astal.go ]; in - buildGoModule { - version = replaceStrings ["\n"] [""] (readFile ./version); - pname = "ags"; - src = ./.; +buildGoModule { + version = replaceStrings [ "\n" ] [ "" ] (readFile ./version); + pname = "ags"; + src = ./.; - vendorHash = "sha256-MXappgAYaFcxYQVck4fxbAFS1Hn9KsoOOpzmZBgxuM0="; + vendorHash = "sha256-MXappgAYaFcxYQVck4fxbAFS1Hn9KsoOOpzmZBgxuM0="; - nativeBuildInputs = [ - wrapGAppsHook - gobject-introspection - ]; + nativeBuildInputs = [ + wrapGAppsHook + gobject-introspection + ]; - buildInputs = extraPackages ++ [ - glib - gtk3 - astal-io - astal3 - ]; + buildInputs = extraPackages ++ [ + glib + gtk3 + astal-io + astal3 + ]; - preFixup = '' - gappsWrapperArgs+=( - --prefix NIX_GI_DIRS : "$(${datadirs})" - --prefix PATH : "${lib.makeBinPath (bins ++ extraPackages)}" - ) - ''; + preFixup = '' + gappsWrapperArgs+=( + --prefix NIX_GI_DIRS : "$(${datadirs})" + --prefix PATH : "${lib.makeBinPath (bins ++ extraPackages)}" + ) + ''; - ldflags = [ - "-X main.astalGjs=${astal-gjs}" - ]; - } + ldflags = [ + "-X main.astalGjs=${astal-gjs}" + ]; +}