-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Lenivaya/feat/nix
- Loading branch information
Showing
9 changed files
with
207 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# The importApply argument. Use this to reference things defined locally, | ||
# as opposed to the flake where this is imported. | ||
localFlake: | ||
|
||
# Regular module arguments; self, inputs, etc all reference the final user flake, | ||
# where this module was imported. | ||
{ | ||
lib, | ||
config, | ||
self, | ||
inputs, | ||
... | ||
}: | ||
let | ||
resterrsMod = localFlake.moduleWithSystem ( | ||
perSystem@{ config }: localFlake.importApply ./nixosModules perSystem | ||
); | ||
in | ||
{ | ||
perSystem = | ||
{ system, ... }: | ||
let | ||
resterrs' = localFlake.withSystem system ( | ||
{ config, pkgs, ... }: pkgs.callPackage ./pkgs/resterrs.nix { inherit inputs; } | ||
); | ||
in | ||
{ | ||
packages.resterrs = resterrs'; | ||
packages.default = resterrs'; | ||
}; | ||
|
||
flake.nixosModules.resterrs = resterrsMod; | ||
flake.nixosModules.default = resterrsMod; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
perSystem: | ||
{ | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: | ||
with lib; | ||
let | ||
cfg = config.services.resterrs; | ||
|
||
inherit (lib.meta) getExe'; | ||
inherit (lib.options) mkEnableOption mkPackageOption mkOption; | ||
|
||
toTOML = pkgs.formats.toml { }; | ||
in | ||
{ | ||
options.services.resterrs = { | ||
enable = mkEnableOption "Resterrs, simple rester"; | ||
package = mkPackageOption pkgs "resterrs" { } // { | ||
default = perSystem.config.packages.resterrs; | ||
}; | ||
|
||
settings = mkOption { | ||
type = toTOML.type; | ||
default = { }; | ||
example = literalExpression '' | ||
system_services_to_stop = ["bpftune", "syncthing", "fwupd"] | ||
user_services_to_stop = ["kdeconnect", "picom"] | ||
apps_to_stop = ["telegram-desktop", "vesktop"] | ||
username = "leniviy" | ||
''; | ||
description = "TOML configuration for Resterrs. See the Resterrs documentation for available options."; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.resterrs = { | ||
description = "Resterrs Service"; | ||
wantedBy = [ "multi-user.target" ]; | ||
after = [ "network.target" ]; | ||
serviceConfig = { | ||
ExecStart = "${getExe' cfg.package "resterrs"} -c ${toTOML.generate "resterrs-config.toml" cfg.settings}"; | ||
Restart = "always"; | ||
RestartSec = "10"; | ||
User = "root"; | ||
DynamicUser = true; | ||
StateDirectory = "resterrs"; | ||
ConfigurationDirectory = "resterrs"; | ||
RuntimeDirectory = "resterrs"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
inputs, | ||
pkgs, | ||
... | ||
}: | ||
let | ||
naersk' = pkgs.callPackage inputs.naersk { }; | ||
inherit (inputs.gitignore.lib) gitignoreSource; | ||
src = gitignoreSource ../../../.; | ||
in | ||
naersk'.buildPackage { | ||
inherit src; | ||
buildInputs = with pkgs; [ | ||
pkg-config | ||
systemd | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ pkgs, self' }: | ||
let | ||
bareMinimum = with pkgs; [ | ||
rustc | ||
cargo | ||
|
||
systemd | ||
pkg-config | ||
]; | ||
in | ||
{ | ||
default = pkgs.mkShell { | ||
name = "resterrs-dev"; | ||
nativeBuildInputs = | ||
with pkgs; | ||
bareMinimum | ||
++ [ | ||
cargo-tarpaulin | ||
cargo-edit | ||
|
||
rustfmt | ||
clippy | ||
|
||
act | ||
]; | ||
RUST_BACKTRACE = 1; | ||
RUST_LOG = "warn,test,info"; | ||
}; | ||
|
||
ci-tests = pkgs.mkShell { | ||
name = "resterrs-ci"; | ||
nativeBuildInputs = bareMinimum ++ (with pkgs; [ cargo-tarpaulin ]); | ||
RUST_BACKTRACE = 1; | ||
}; | ||
|
||
ci-format = pkgs.mkShell { | ||
name = "resterrs-ci-format"; | ||
nativeBuildInputs = | ||
bareMinimum | ||
++ (with pkgs; [ | ||
rustfmt | ||
clippy | ||
]); | ||
}; | ||
|
||
testing = pkgs.mkShell { | ||
name = "resterrs-test"; | ||
nativeBuildInputs = [ self'.packages.default ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
_: { | ||
projectRootFile = "flake.nix"; | ||
|
||
programs = { | ||
nixfmt.enable = true; | ||
rustfmt.enable = true; | ||
yamlfmt.enable = true; | ||
prettier.enable = true; | ||
}; | ||
} |
Oops, something went wrong.