This commit is contained in:
Olivier 'reivilibre' 2022-04-05 19:41:14 +01:00
parent 360a902263
commit ca45371d40
8 changed files with 338 additions and 3 deletions

4
.gitignore vendored
View File

@ -16,4 +16,6 @@ qp_web.ron
/rakepacks /rakepacks
/index /index
qp_indexer.toml qp_indexer.toml
nix_flake/result nix_flake/result
nix_flake/test_vm/nixos.qcow2
nix_flake/test_vm/result

View File

@ -33,11 +33,15 @@
popd popd
''; '';
}; };
}; };
defaultPackage = packages.quickpeep; defaultPackage = packages.quickpeep;
# NixOS Modules
nixosModules = {
quickpeepSearch = import ./modules/quickpeepSearch.nix;
};
# `nix run` # `nix run`
apps.quickpeep = utils.lib.mkApp { apps.quickpeep = utils.lib.mkApp {
drv = packages.quickpeep; drv = packages.quickpeep;

View File

@ -0,0 +1,61 @@
{config, pkgs, lib, quickpeep, ...}:
let
cfg = config.services.quickpeepSearch;
in
with lib;
{
options = {
services.quickpeepSearch = {
enable = mkOption {
default = false;
type = with types; bool;
description = ''
Start the QuickPeep Search web interface.
'';
};
user = mkOption {
default = "quickpeep";
type = with types; uniq string;
description = ''
Name of the user.
'';
};
bindHost = mkOption {
default = "127.0.0.1";
type = with types; string;
description = ''
Host upon which to bind the web interface.
'';
};
bindPort = mkOption {
default = 9733;
type = with types; int;
description = ''
Port upon which to bind the web interface.
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.quickpeepSearch = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
description = "Start the QuickPeep Search web interface.";
serviceConfig = {
Type = "simple";
User = "${cfg.user}";
ExecStart = ''${quickpeep.quickpeep}/bin/quickpeep ${cfg.bindHost}:${cfg.bindPort}'';
};
};
# TODO Do we need to specify quickpeep here?
environment.systemPackages = [ quickpeep.quickpeep ];
};
}

View File

@ -0,0 +1,10 @@
# Test VM for the QuickPeep Nix Flake
To build and start a test VM, in this directory, with a copy of Nix that supports flakes, run:
```shell
nix build .#nixosConfigurations.testvm.config.system.build.vm -j8
./result/bin/run-nixos-vm
```
(An amd64 system is needed for now; otherwise you need to edit `outputs.nix`.)

View File

@ -0,0 +1,189 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"lowdown-src": {
"flake": false,
"locked": {
"lastModified": 1633514407,
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
"owner": "kristapsdz",
"repo": "lowdown",
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
"type": "github"
},
"original": {
"owner": "kristapsdz",
"repo": "lowdown",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1648544490,
"narHash": "sha256-EoBDcccV70tfz2LAs5lK0BjC7en5mzUVlgLsd5E6DW4=",
"owner": "nix-community",
"repo": "naersk",
"rev": "e30ef9a5ce9b3de8bb438f15829c50f9525ca730",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": "nixpkgs",
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1646680282,
"narHash": "sha256-m8tqCS6uHveDon5GSro5yZor9H+sHeh+v/veF1IGw24=",
"owner": "NixOS",
"repo": "nix",
"rev": "ffe155abd36366a870482625543f9bf924a58281",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "2.7.0",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1632864508,
"narHash": "sha256-d127FIvGR41XbVRDPVvozUPQ/uRHbHwvfyKHwEt5xFM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "82891b5e2c2359d7e58d08849e4c89511ab94234",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-21.05-small",
"type": "indirect"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"id": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1648383610,
"narHash": "sha256-egKvd+S5FEpjwK2aCoJ+NrBG2m+9Njl4I1OXrDTZHvE=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "7a3f9d626c8a88141077ab99d8352469aa6feeb7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1648219316,
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_4": {
"locked": {
"lastModified": 1648219316,
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "30d3d79b7d3607d56546dd2a6b49e156ba0ec634",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"quickpeep": {
"inputs": {
"naersk": "naersk",
"nixpkgs": "nixpkgs_4",
"utils": "utils"
},
"locked": {
"narHash": "sha256-sIsKWG16MmzhkFFyHBgRPeSnREpDY1ylPjCBKhogsjs=",
"path": "..",
"type": "path"
},
"original": {
"path": "..",
"type": "path"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nix": "nix",
"nixpkgs": "nixpkgs_2",
"quickpeep": "quickpeep"
}
},
"utils": {
"locked": {
"lastModified": 1648297722,
"narHash": "sha256-W+qlPsiZd8F3XkzXOzAoR+mpFqzm3ekQkJNa+PIh1BQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "0f8662f1319ad6abf89b3380dd2722369fc51ade",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@ -0,0 +1,18 @@
{
description = "NixOS Test VM Flake";
# To update all inputs:
# $ nix flake update --recreate-lock-file
# (rei: think this may now be nix flake lock)
inputs = {
nix.url = "github:NixOS/nix/2.7.0";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11";
# Useful for arch-independent flakes
flake-utils.url = "github:numtide/flake-utils";
quickpeep.url = "path:..";
};
outputs = { ... } @ args: import ./outputs.nix args;
}

View File

@ -0,0 +1,15 @@
{ config, pkgs, ... }:
{
imports = [
];
# Add a test user who can sudo to the root account for debugging
users.extraUsers.vm = {
isNormalUser = true;
password = "vm";
shell = "${pkgs.bash}/bin/bash";
group = "wheel";
};
services.quickpeepSearch.enable = true;
}

View File

@ -0,0 +1,36 @@
{ self,
nix,
nixpkgs,
flake-utils,
quickpeep
}:
(
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
# This lets you type `nix develop` to get needed tools.
#devShell = pkgs.callPackage ./shell.nix {};
# TODO figure this out devShells.${system}.default = pkgs.callPackage ./shell.nix {};
}
)
) // {
nixosConfigurations = {
testvm = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{
nix.nixPath = [
"nixpkgs=${nixpkgs}"
];
nix.registry = {
nixpkgs.flake = nixpkgs;
};
}
# TODO quickpeep.nixosModules.quickpeepSearch Fix needed: ${system} or equivalent..?
quickpeep.nixosModules."x86_64-linux".quickpeepSearch
./nixos_config.nix
];
};
};
}