update nextcloud module, cleanup

This commit is contained in:
Jonas Heinrich 2024-01-23 14:56:44 +01:00
parent 982b8f7d7c
commit bc7778e46c
4 changed files with 136 additions and 109 deletions

60
flake.lock generated
View file

@ -1,57 +1,57 @@
{
"nodes": {
"flake-utils": {
"nixos-shell": {
"inputs": {
"systems": "systems"
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"lastModified": 1698737528,
"narHash": "sha256-65qiCQPFGCpdjcfQrO1EZKe+LFD0tzmlecFOACNwMbY=",
"owner": "Mic92",
"repo": "nixos-shell",
"rev": "8a835e240adc32e68d6fc7ca5aaf3f597de08d5f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "Mic92",
"repo": "nixos-shell",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1701282334,
"narHash": "sha256-MxCVrXY6v4QmfTwIysjjaX0XUhqBbxTWWB4HXtDYsdk=",
"lastModified": 1628465643,
"narHash": "sha256-QSNw9bDq9uGUniQQtakRuw4m21Jxugm23SXLVgEV4DM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "057f9aecfb71c4437d2b27d3323df7f93c010b7e",
"rev": "6ef4f522d63f22b40004319778761040d3197390",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "23.11",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1705916986,
"narHash": "sha256-iBpfltu6QvN4xMpen6jGGEb6jOqmmVQKUrXdOJ32u8w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d7f206b723e42edb09d9d753020a84b3061a79d8",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-23.11",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
"nixos-shell": "nixos-shell",
"nixpkgs": "nixpkgs_2"
}
}
},

View file

@ -1,33 +1,43 @@
{
description = "Spawns lightweight nixos vm in a shell";
inputs = {
# FIXME
#nixpkgs.url = "nixpkgs/23.11";
nixpkgs.url = "github:onny/nixpkgs/nextcloud-update2";
# Required for multi platform support
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixos-23.11";
nixos-shell.url = "github:Mic92/nixos-shell";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
outputs = { self, nixpkgs, nixos-shell }: let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
start =
pkgs.writeShellScriptBin "start" ''
set -e
export QEMU_NET_OPTS="hostfwd=tcp::8080-:80,hostfwd=tcp::1433-:143,hostfwd=tcp::5877-:587"
${pkgs.nixos-shell}/bin/nixos-shell vm-nextcloud.nix
${pkgs.nixos-shell}/bin/nixos-shell --flake .
'';
in
{
devShell = pkgs.mkShell {
packages = with pkgs; [
in {
nixosConfigurations.vm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(import ./vm-nextcloud.nix)
nixos-shell.nixosModules.nixos-shell
];
};
devShells.x86_64-linux = {
default = with pkgs; mkShell {
nativeBuildInputs = [
php82Packages.composer
phpunit
nodejs
nodePackages.rollup
];
};
packages = { inherit start; };
defaultPackage = start;
});
}
};
packages = { inherit start; };
defaultPackage.x86_64-linux = start;
};
}

62
nixos-shell.nix Normal file
View file

@ -0,0 +1,62 @@
{ lib, modulesPath, ... }:
{
imports = [
"${toString modulesPath}/virtualisation/qemu-vm.nix"
];
options.nixos-shell = with lib; {
mounts = let
cache = mkOption {
type = types.enum ["none" "loose" "fscache" "mmap"];
default = "loose"; # bad idea? Well, at least it is fast!1!!
description = "9p caching policy";
};
in {
mountHome = mkOption {
type = types.bool;
default = true;
description = "Whether to mount `/home`.";
};
mountNixProfile = mkOption {
type = types.bool;
default = true;
description = "Whether to mount the user's nix profile.";
};
inherit cache;
extraMounts = mkOption {
type = types.attrsOf (types.coercedTo
types.path (target: {
inherit target;
})
(types.submodule ({ config, ... }: {
options = {
target = mkOption {
type = types.path;
description = lib.mdDoc "Target on the guest.";
};
inherit cache;
tag = mkOption {
type = types.str;
internal = true;
};
};
config.tag = lib.mkDefault (
builtins.substring 0 31 ( # tags must be shorter than 32 bytes
"a" + # tags must not begin with a digit
builtins.hashString "md5" config._module.args.name
)
);
}))
);
default = {};
};
};
};
}

View file

@ -95,61 +95,16 @@
trusted_domains = [ "10.100.100.1" ];
"integrity.check.disabled" = true;
debug = true;
apps_paths = [
{
path = "/var/lib/nextcloud/nix-apps";
url = "/nix-apps";
writable = false;
}
{
path = "/var/lib/nextcloud/apps";
url = "/apps";
writable = false;
}
{
path = "/var/lib/nextcloud/store-apps";
url = "/store-apps";
writable = true;
}
];
};
};
nixos-shell.mounts.extraMounts = {
"/var/lib/nextcloud/cleanup" = {
target = ./cleanup;
"/var/lib/nextcloud/store-apps/cleanup" = {
target = /home/onny/projects/nixos-nextcloud-testumgebung/cleanup;
cache = "none";
};
};
systemd.mounts = [
{
what = "/var/lib/nextcloud/cleanup";
where = "/var/lib/nextcloud/store-apps/cleanup";
type = "fuse.bindfs";
options = "uid=997,gid=997";
wantedBy = [ "multi-user.target" ];
enable = true;
}
];
systemd.services."prepare-bindfs-mount" = {
script = ''
set -eu
${pkgs.coreutils}/bin/mkdir -p /var/lib/nextcloud/store-apps
${pkgs.coreutils}/bin/chown nextcloud:nextcloud /var/lib/nextcloud/store-apps
'';
before = [
"nextcloud-setup.service"
"var-lib-nextcloud-store\\x2dapps-calendar.mount"
];
wantedBy = ["multi-user.target"];
serviceConfig = {
Type = "oneshot";
User = "root";
};
};
# Setup mail server
services.maddy = {
enable = true;
@ -191,7 +146,7 @@
};
};
system.fsPackages = [ pkgs.bindfs ];
#system.fsPackages = [ pkgs.bindfs ];
system.stateVersion = "23.11";