adding nixosModule and test
This commit is contained in:
48
flake.nix
48
flake.nix
@@ -1,38 +1,50 @@
|
||||
{
|
||||
description = "A very basic flake";
|
||||
|
||||
outputs = { self, nixpkgs }: {
|
||||
#nixpkgs for testing framework
|
||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
outputs = { self, nixpkgs, ... }: let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
|
||||
in
|
||||
{
|
||||
|
||||
packages.x86_64-linux.tasklist = nixpkgs.legacyPackages.x86_64-linux.buildGoModule rec {
|
||||
pname = "tasklist";
|
||||
version = "1.0";
|
||||
vendorHash = "sha256-olHQNClxU4sykBlhlbvTL6wCUYkMxnaQdLnRwvuJffw=";
|
||||
src = ./.;
|
||||
|
||||
postInstall = ''
|
||||
cp forms.html $out/
|
||||
'';
|
||||
};
|
||||
|
||||
nixosModules.malobeo-tasklist = { config, ... }:
|
||||
nixosModules.malobeo-tasklist = { config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.services.malobeo-tasklist;
|
||||
tasklist-pkg = self.packages.x86_64-linux.tasklist;
|
||||
pkgs = nixpkgs.legacyPackages."x86_64-linux";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.malobeo-tasklist = {
|
||||
enable = nixpkgs.lib.mkOption {
|
||||
enable = lib.mkOption {
|
||||
default = false;
|
||||
type = nixpkgs.types.bool;
|
||||
description = nixpkgs.lib.mdDoc ''
|
||||
type = lib.types.bool;
|
||||
description = lib.mdDoc ''
|
||||
Enables tasklist
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = nixpkgs.lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ tasklist-pkg];
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ tasklist-pkg ];
|
||||
|
||||
users.users = {
|
||||
malobeo-tasklist = {
|
||||
users = {
|
||||
groups.malobeo-tasklist = {};
|
||||
users.malobeo-tasklist = {
|
||||
description = "malobeo tasklist user";
|
||||
group = "malobeo-tasklist";
|
||||
isNormalUser = true;
|
||||
@@ -43,18 +55,32 @@
|
||||
description = "malobeo tasklist daemon";
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${tasklist-pkg}/bin/tasklist -d /var/lib/malobeo-tasklist/tasklist.db";
|
||||
ExecStart = "${tasklist-pkg}/bin/tasklist -d /var/lib/malobeo-tasklist/tasklist.db -f ${tasklist-pkg}/forms.html";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
|
||||
preStart = ''
|
||||
mkdir -m 0770 -p "/var/lib/malobeo-tasklist"
|
||||
chown malobeo-tasklist:malobeo-tasklist "/var/lib/malobeo-tasklist"
|
||||
'';
|
||||
|
||||
wantedBy = [ "default.target" ];
|
||||
|
||||
environment = {
|
||||
USER = "malobeo-tasklist";
|
||||
HOME = /var/lib/malobeo-tasklist;
|
||||
HOME = "/var/lib/malobeo-tasklist";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
checks = forAllSystems (system: let
|
||||
checkArgs = {
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
inherit self;
|
||||
};
|
||||
in {
|
||||
malobeo-tasklist = import ./test/test.nix checkArgs;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user