WIP
This commit is contained in:
parent
3525fa2f04
commit
56db4d295e
12
flake.nix
12
flake.nix
|
@ -13,5 +13,15 @@
|
|||
loomio = pkgs.callPackage ./pkg/loomio/default.nix {};
|
||||
inherit pkgs;
|
||||
};
|
||||
});
|
||||
}) // {
|
||||
nixosConfigurations = {
|
||||
test-vm = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
(import ./modules/overlay.nix)
|
||||
./hosts/test/configuration.nix
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
54
hosts/test/configuration.nix
Normal file
54
hosts/test/configuration.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{pkgs, ...}: {
|
||||
virtualisation.vmVariant = {
|
||||
# following configuration is added only when building VM with build-vm
|
||||
virtualisation = {
|
||||
memorySize = 2048; # Use 2048MiB memory.
|
||||
cores = 3;
|
||||
};
|
||||
};
|
||||
|
||||
users.users.root.openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNeQYLFauAbzDyIbKC86NUh9yZfiyBm/BtIdkcpZnSU"
|
||||
];
|
||||
|
||||
services.openssh.enable = true;
|
||||
users.users.root.initialPassword = "root";
|
||||
|
||||
users.users.nixosvmtest.isSystemUser = true ;
|
||||
users.users.nixosvmtest.initialPassword = "test";
|
||||
users.users.nixosvmtest.group = "nixosvmtest";
|
||||
users.groups.nixosvmtest = {};
|
||||
|
||||
users.groups.loomio = {};
|
||||
users.users.loomio = {
|
||||
description = "User to run loomio";
|
||||
group = "loomio";
|
||||
isSystemUser = true;
|
||||
};
|
||||
|
||||
services.postgresql = {
|
||||
enable = true;
|
||||
ensureDatabases = [ "loomio" ];
|
||||
ensureUsers = [{
|
||||
name = "loomio";
|
||||
ensureDBOwnership = true;
|
||||
# ensurePermissions = { "DATABASE loomio" = "ALL PRIVILEGES"; };
|
||||
}];
|
||||
};
|
||||
|
||||
systemd.services.loomio = {
|
||||
enable = true;
|
||||
after = [ "basic.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
User = "loomio";
|
||||
Restart = "always";
|
||||
ExecStart = "${pkgs.loomio}/bin/loomio";
|
||||
};
|
||||
environment = {
|
||||
DATABASE_URL = "postgresql://localhost/loomio";
|
||||
};
|
||||
};
|
||||
|
||||
system.stateVersion = "23.11";
|
||||
}
|
7
modules/overlay.nix
Normal file
7
modules/overlay.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
{config, pkgs, ...}: {
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
loomio = super.callPackage ../pkg/loomio {};
|
||||
})
|
||||
];
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
{stdenv, callPackage, bundlerEnv, ruby_3_2 }:
|
||||
{stdenv, writeText, callPackage, bundlerEnv, ruby_3_2 }:
|
||||
|
||||
let
|
||||
gemfile-patch = callPackage ./gemfile-patch.nix {};
|
||||
|
@ -9,6 +9,11 @@ let
|
|||
gemset = ./. + "/gemset.nix";
|
||||
gemdir = src;
|
||||
};
|
||||
|
||||
databaseConfig = writeText "database.yml" ''
|
||||
production:
|
||||
url: <%= ENV['DATABASE_URL'] %>
|
||||
'';
|
||||
in stdenv.mkDerivation {
|
||||
name = "loomio";
|
||||
inherit src;
|
||||
|
@ -17,11 +22,13 @@ in stdenv.mkDerivation {
|
|||
mkdir -p $out/{bin,share/loomio}
|
||||
cp -r * $out/share/loomio
|
||||
bin=$out/bin/loomio
|
||||
cp ${databaseConfig} $out/share/loomio/config/database.yml
|
||||
cat > $bin <<EOF
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
export BUNDLE_FORCE_RUBY_PLATFORM=true
|
||||
export RAILS_ENV=production
|
||||
${gems}/bin/bundle exec rake -f $out/share/loomio/Rakefile db:prepare
|
||||
${gems}/bin/bundle exec puma -C $out/share/loomio/config/puma.rb
|
||||
|
||||
|
|
Loading…
Reference in a new issue