diff --git a/flake.nix b/flake.nix index 0f84654..b45f110 100644 --- a/flake.nix +++ b/flake.nix @@ -3,22 +3,27 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - outputs = { - nixpkgs, - self, - ... - }: let - forAllSystems = nixpkgs.lib.genAttrs ["x86_64-linux" "x86_64-darwin" "i686-linux" "aarch64-linux" "aarch64-darwin"]; - pkgsForEach = nixpkgs.legacyPackages; - in { - packages = forAllSystems (system: { - default = pkgsForEach.${system}.callPackage ./nix/default.nix {}; - }); + outputs = + { nixpkgs, self, ... }: + let + forAllSystems = nixpkgs.lib.genAttrs [ + "x86_64-linux" + "x86_64-darwin" + "i686-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + pkgsForEach = nixpkgs.legacyPackages; + in + { + packages = forAllSystems (system: { + default = pkgsForEach.${system}.callPackage ./nix/default.nix { }; + }); - devShells = forAllSystems (system: { - default = pkgsForEach.${system}.callPackage ./nix/shell.nix {}; - }); + devShells = forAllSystems (system: { + default = pkgsForEach.${system}.callPackage ./nix/shell.nix { }; + }); - nixosModules.default = import ./nix/module.nix self; - }; + nixosModules.default = import ./nix/module.nix self; + }; } diff --git a/nix/module.nix b/nix/module.nix index 1f18aaf..2d6bbd0 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -1,25 +1,26 @@ -self: { +self: +{ pkgs, config, lib, ... -}: let +}: +let inherit (lib) mkIf mkEnableOption getExe; -in { +in +{ options.services.isabelroses-website.enable = mkEnableOption "isabelroses-website"; config = mkIf config.services.isabelroses-website.enable { systemd.services."isabelroses-website" = { description = "isabelroses.com"; - after = ["network.target"]; - wantedBy = ["multi-user.target"]; - path = [ - self.packages.${pkgs.stdenv.hostPlatform.system}.default - ]; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ self.packages.${pkgs.stdenv.hostPlatform.system}.default ]; serviceConfig = { Type = "simple"; - ReadWritePaths = ["/srv/storage/isabelroses.com"]; + ReadWritePaths = [ "/srv/storage/isabelroses.com" ]; DynamicUser = true; ExecStart = "${getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default}"; Restart = "always"; diff --git a/nix/shell.nix b/nix/shell.nix index 6889669..863a928 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -5,17 +5,16 @@ gopls, typos, callPackage, -}: let - mainPkg = callPackage ./default.nix {}; +}: +let + mainPkg = callPackage ./default.nix { }; in - mainPkg.overrideAttrs (oa: { - nativeBuildInputs = - [ - go - bun - air - gopls - typos - ] - ++ (oa.nativeBuildInputs or []); - }) +mainPkg.overrideAttrs (oa: { + nativeBuildInputs = [ + go + bun + air + gopls + typos + ] ++ (oa.nativeBuildInputs or [ ]); +})