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": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1649667661, "lastModified": 1650097359,
"narHash": "sha256-9cbstidkXdAC3ZzokV6clgCoeLSbbs2tis9KFsqCzTM=", "narHash": "sha256-5yz+ws47yxpu2BOZr8+Ht9t44yPsb6kWz1r1eftLg0I=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a48aeae76ad50bb15ad9bda2cf51d7ae5c621853", "rev": "70d0e2456857dc10dd7d2654277fc1dd8d8cc216",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

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