Skip to content

Commit

Permalink
nix: set formatter to nixfmt-rfc-style
Browse files Browse the repository at this point in the history
  • Loading branch information
olifloof committed Nov 1, 2024
1 parent 65aa0bf commit 7c0f8cf
Show file tree
Hide file tree
Showing 2 changed files with 204 additions and 186 deletions.
321 changes: 168 additions & 153 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ];
};
};
})
]);
};
};
};
}
Loading

0 comments on commit 7c0f8cf

Please sign in to comment.