forked from fediversity/fediversity
Compare commits
3 commits
350245c097
...
1fcba0942d
Author | SHA1 | Date | |
---|---|---|---|
1fcba0942d | |||
87a20886cd | |||
191d2c4d43 |
6 changed files with 92 additions and 69 deletions
119
flake.nix
119
flake.nix
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; # consumed by flake-parts
|
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
git-hooks.url = "github:cachix/git-hooks.nix";
|
git-hooks.url = "github:cachix/git-hooks.nix";
|
||||||
nixops4.follows = "nixops4-nixos/nixops4";
|
nixops4.follows = "nixops4-nixos/nixops4";
|
||||||
|
@ -11,62 +10,70 @@
|
||||||
inputs@{ flake-parts, ... }:
|
inputs@{ flake-parts, ... }:
|
||||||
let
|
let
|
||||||
sources = import ./npins;
|
sources = import ./npins;
|
||||||
|
inherit (import "${sources.flake-inputs}/lib.nix") import-flake;
|
||||||
inherit (sources) git-hooks agenix;
|
inherit (sources) git-hooks agenix;
|
||||||
|
nixpkgs = import-flake sources.nixpkgs;
|
||||||
in
|
in
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake
|
||||||
systems = [
|
{
|
||||||
"x86_64-linux"
|
inputs = inputs // {
|
||||||
"aarch64-linux"
|
inherit nixpkgs;
|
||||||
"x86_64-darwin"
|
|
||||||
"aarch64-darwin"
|
|
||||||
];
|
|
||||||
|
|
||||||
imports = [
|
|
||||||
(import "${git-hooks}/flake-module.nix")
|
|
||||||
inputs.nixops4.modules.flake.default
|
|
||||||
|
|
||||||
./deployment/flake-part.nix
|
|
||||||
./infra/flake-part.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
perSystem =
|
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
inputs',
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
|
||||||
formatter = pkgs.nixfmt-rfc-style;
|
|
||||||
|
|
||||||
pre-commit.settings.hooks =
|
|
||||||
let
|
|
||||||
## Add a directory here if pre-commit hooks shouldn't apply to it.
|
|
||||||
optout = [ "npins" ];
|
|
||||||
excludes = map (dir: "^${dir}/") optout;
|
|
||||||
addExcludes = lib.mapAttrs (_: c: c // { inherit excludes; });
|
|
||||||
in
|
|
||||||
addExcludes {
|
|
||||||
nixfmt-rfc-style.enable = true;
|
|
||||||
deadnix.enable = true;
|
|
||||||
trim-trailing-whitespace.enable = true;
|
|
||||||
shellcheck.enable = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = [
|
|
||||||
pkgs.npins
|
|
||||||
pkgs.nil
|
|
||||||
(pkgs.callPackage "${agenix}/pkgs/agenix.nix" { })
|
|
||||||
pkgs.openssh
|
|
||||||
pkgs.httpie
|
|
||||||
pkgs.jq
|
|
||||||
# exposing this env var as a hack to pass info in from form
|
|
||||||
(inputs'.nixops4.packages.default.overrideAttrs {
|
|
||||||
impureEnvVars = [ "DEPLOYMENT" ];
|
|
||||||
})
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
|
{
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-darwin"
|
||||||
|
"aarch64-darwin"
|
||||||
|
];
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
(import "${git-hooks}/flake-module.nix")
|
||||||
|
inputs.nixops4.modules.flake.default
|
||||||
|
|
||||||
|
./deployment/flake-part.nix
|
||||||
|
./infra/flake-part.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
perSystem =
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
inputs',
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
formatter = pkgs.nixfmt-rfc-style;
|
||||||
|
|
||||||
|
pre-commit.settings.hooks =
|
||||||
|
let
|
||||||
|
## Add a directory here if pre-commit hooks shouldn't apply to it.
|
||||||
|
optout = [ "npins" ];
|
||||||
|
excludes = map (dir: "^${dir}/") optout;
|
||||||
|
addExcludes = lib.mapAttrs (_: c: c // { inherit excludes; });
|
||||||
|
in
|
||||||
|
addExcludes {
|
||||||
|
nixfmt-rfc-style.enable = true;
|
||||||
|
deadnix.enable = true;
|
||||||
|
trim-trailing-whitespace.enable = true;
|
||||||
|
shellcheck.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
packages = [
|
||||||
|
pkgs.npins
|
||||||
|
pkgs.nil
|
||||||
|
(pkgs.callPackage "${agenix}/pkgs/agenix.nix" { })
|
||||||
|
pkgs.openssh
|
||||||
|
pkgs.httpie
|
||||||
|
pkgs.jq
|
||||||
|
# exposing this env var as a hack to pass info in from form
|
||||||
|
(inputs'.nixops4.packages.default.overrideAttrs {
|
||||||
|
impureEnvVars = [ "DEPLOYMENT" ];
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,22 @@
|
||||||
"url": null,
|
"url": null,
|
||||||
"hash": "1w2gsy6qwxa5abkv8clb435237iifndcxq0s79wihqw11a5yb938"
|
"hash": "1w2gsy6qwxa5abkv8clb435237iifndcxq0s79wihqw11a5yb938"
|
||||||
},
|
},
|
||||||
|
"flake-inputs": {
|
||||||
|
"type": "GitRelease",
|
||||||
|
"repository": {
|
||||||
|
"type": "GitHub",
|
||||||
|
"owner": "fricklerhandwerk",
|
||||||
|
"repo": "flake-inputs"
|
||||||
|
},
|
||||||
|
"pre_releases": false,
|
||||||
|
"version_upper_bound": null,
|
||||||
|
"release_prefix": null,
|
||||||
|
"submodules": false,
|
||||||
|
"version": "1.1",
|
||||||
|
"revision": "6461d0b56e790bf289af07c5e5261abbf4f536af",
|
||||||
|
"url": "https://api.github.com/repos/fricklerhandwerk/flake-inputs/tarball/1.1",
|
||||||
|
"hash": "03mwisvr1mc3nd33nvg4bvcyxjxpm4lwhwym39r0768cm1007ixl"
|
||||||
|
},
|
||||||
"flake-parts": {
|
"flake-parts": {
|
||||||
"type": "Git",
|
"type": "Git",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -9,10 +9,4 @@ in
|
||||||
{
|
{
|
||||||
REPO_DIR = toString ../.;
|
REPO_DIR = toString ../.;
|
||||||
# explicitly use nix, as e.g. lix does not have configurable-impure-env
|
# explicitly use nix, as e.g. lix does not have configurable-impure-env
|
||||||
BIN_PATH = lib.makeBinPath [
|
|
||||||
# explicitly use nix, as e.g. lix does not have configurable-impure-env
|
|
||||||
pkgs.nix
|
|
||||||
# nixops error maybe due to our flake git hook: executing 'git': No such file or directory
|
|
||||||
pkgs.git
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,10 +178,18 @@ in
|
||||||
description = "${name} ASGI server";
|
description = "${name} ASGI server";
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
path = [
|
path =
|
||||||
python-environment
|
[
|
||||||
manage-service
|
python-environment
|
||||||
];
|
manage-service
|
||||||
|
]
|
||||||
|
++ (
|
||||||
|
with pkgs;
|
||||||
|
lib.makeBinPath [
|
||||||
|
nix
|
||||||
|
git
|
||||||
|
]
|
||||||
|
);
|
||||||
preStart = ''
|
preStart = ''
|
||||||
# Auto-migrate on first run or if the package has changed
|
# Auto-migrate on first run or if the package has changed
|
||||||
versionFile="/var/lib/${name}/package-version"
|
versionFile="/var/lib/${name}/package-version"
|
||||||
|
|
|
@ -240,8 +240,6 @@ if user_settings_file is not None:
|
||||||
# The correct thing to do here would be using a helper function such as with `get_secret()` that will catch the exception and explain what's wrong and where to put the right values.
|
# The correct thing to do here would be using a helper function such as with `get_secret()` that will catch the exception and explain what's wrong and where to put the right values.
|
||||||
# Replacing the `USER_SETTINGS_FILE` mechanism following the comment there would probably be a good thing.
|
# Replacing the `USER_SETTINGS_FILE` mechanism following the comment there would probably be a good thing.
|
||||||
|
|
||||||
# PATH to expose to launch button
|
|
||||||
bin_path=env['BIN_PATH']
|
|
||||||
# path of the root flake to trigger nixops from, see #94.
|
# path of the root flake to trigger nixops from, see #94.
|
||||||
# to deploy this should be specified, for dev just use a relative path.
|
# to deploy this should be specified, for dev just use a relative path.
|
||||||
repo_dir = env["REPO_DIR"]
|
repo_dir = env["REPO_DIR"]
|
||||||
|
|
|
@ -89,7 +89,7 @@ class DeploymentStatus(ConfigurationForm):
|
||||||
|
|
||||||
def deployment(self, config: BaseModel):
|
def deployment(self, config: BaseModel):
|
||||||
env = {
|
env = {
|
||||||
"PATH": settings.bin_path,
|
"PATH": os.environ.get("PATH"),
|
||||||
# pass in form info to our deployment
|
# pass in form info to our deployment
|
||||||
"DEPLOYMENT": config.json()
|
"DEPLOYMENT": config.json()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue