EVERYTHING WORKS!!!

now i have to set up a server and the refresh module to update poonam
input
This commit is contained in:
Anish Lakhwara 2022-04-16 19:33:30 +10:00
parent 613d4447bf
commit 84d6809cc2
2 changed files with 44 additions and 46 deletions

View file

@ -32,11 +32,11 @@
},
"nixpkgs_2": {
"locked": {
"lastModified": 1649667661,
"narHash": "sha256-9cbstidkXdAC3ZzokV6clgCoeLSbbs2tis9KFsqCzTM=",
"lastModified": 1650097359,
"narHash": "sha256-5yz+ws47yxpu2BOZr8+Ht9t44yPsb6kWz1r1eftLg0I=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "a48aeae76ad50bb15ad9bda2cf51d7ae5c621853",
"rev": "70d0e2456857dc10dd7d2654277fc1dd8d8cc216",
"type": "github"
},
"original": {

View file

@ -60,50 +60,48 @@
'';
};
defaultPackage = self.packages.${system}.site;
# also need a module that refreshes this flake.lock, but maybe that shouldn't live here?
nixosModule = { options, lib, config, pkgs, ... }:
let
serverName = "anish.lakhwara.com";
webRoot = "/var/www/${serverName}";
serviceConfig = config.services."${serverName}";
options = {
enable = lib.mkEnableOption "${serverName} service";
};
in
{
options.services.${serverName} = options;
config = lib.mkIf serviceConfig.enable {
systemd.services."source-${serverName}" = {
description = ''
https://${serverName} source
'';
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
DynamicUser = "yes";
};
startAt = "*00:00:00";
path = with pkgs; [ nix gnutar gzip curl jq ] ++ [ self.packages.${system}.site ];
script = ''
set -ex
ln -sfT ${self.packages.${system}.site} ${webRoot}
'';
};
# Allow nginx through the firewall
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx.enable = true;
services.nginx.virtualHosts.${serverName} = {
forceSSL = true;
enableACME = true;
locations."/" = { root = "${webRoot}"; };
};
};
};
}) // {
# also need a module that refreshes this flake.lock, but maybe that shouldn't live here?
nixosModule = { options, lib, config, pkgs, ... }:
let
serverName = "anish.lakhwara.com";
webRoot = "/var/www/";
serviceConfig = config.services."${serverName}";
options = {
enable = lib.mkEnableOption "${serverName} service";
};
in
{
options.services.${serverName} = options;
config = lib.mkIf serviceConfig.enable {
systemd.services."source-${serverName}" = {
description = ''
https://${serverName} source
'';
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
};
startAt = "*00:00:00";
path = with pkgs; [ nix ] ++ [ self.packages.${system}.site ];
script = ''
set -ex
mkdir -p ${webRoot}
ln -sfT ${self.packages.${pkgs.system}.site} ${webRoot}${serverName}
'';
};
# Allow nginx through the firewall
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx.enable = true;
services.nginx.virtualHosts.${serverName} = {
#forceSSL = true;
#enableACME = true;
locations."/" = { root = "${webRoot}${serverName}"; index = "/home.html"; };
};
};
};
# Test container
nixosConfigurations."test" = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";