flake.nix (4321B) - Raw
1 { 2 nixConfig = { 3 trusted-substituters = "https://cache.nixos.org/"; 4 trusted-public-keys = "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="; 5 extra-experimental-features = "nix-command flakes"; 6 }; 7 inputs = { 8 nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; 9 flake-utils.url = "github:numtide/flake-utils"; 10 geoip2-tarball = { 11 url = "https://dl.jakstys.lt/_/2024.01.13.tar.zst"; 12 flake = false; 13 }; 14 15 flake-compat.url = "github:nix-community/flake-compat"; 16 gitignore.url = "github:hercules-ci/gitignore.nix"; 17 gitignore.inputs.nixpkgs.follows = "nixpkgs"; 18 19 pre-commit-hooks = { 20 url = "github:cachix/pre-commit-hooks.nix"; 21 inputs = { 22 nixpkgs.follows = "nixpkgs"; 23 nixpkgs-stable.follows = "nixpkgs"; 24 flake-compat.follows = "flake-compat"; 25 flake-utils.follows = "flake-utils"; 26 gitignore.follows = "gitignore"; 27 }; 28 }; 29 }; 30 outputs = { 31 self, 32 nixpkgs, 33 flake-utils, 34 pre-commit-hooks, 35 geoip2-tarball, 36 ... 37 }: let 38 overlay = import ./overlays/default.nix geoip2-tarball; 39 in 40 flake-utils.lib.eachDefaultSystem (system: let 41 pkgs = import nixpkgs { 42 inherit system; 43 overlays = [overlay (import ./overlays/django5.nix)]; 44 }; 45 in { 46 packages = { 47 inherit 48 (pkgs) 49 e11sync-blog 50 e11sync-static 51 e11sync-djangostatic 52 e11sync-caddyfile 53 e11sync-backend 54 ; 55 }; 56 57 checks = { 58 e11sync-unit = pkgs.e11sync-backend.passthru.tests.unit; 59 pre-commit-check = pre-commit-hooks.lib.${system}.run { 60 src = ./.; 61 hooks = { 62 alejandra.enable = true; 63 deadnix.enable = true; 64 statix.enable = true; 65 flake8.enable = true; 66 autopep8 = { 67 enable = true; 68 entry = "${pkgs.python3Packages.autopep8}/bin/autopep8 -i"; 69 files = "\\.py$"; 70 }; 71 markdownlint.enable = true; 72 unit-tests = { 73 enable = false; 74 # ?? this is a directory, how do I run the script? 75 #entry = pkgs.e11sync-backend.passthru.tests.unit.buildCommand; 76 pass_filenames = false; 77 }; 78 }; 79 }; 80 build-vm = self.nixosConfigurations.vm.config.system.build.vm; 81 }; 82 83 apps = { 84 e11sync-caddy = { 85 type = "app"; 86 name = "e11sync-caddyfile"; 87 program = toString (pkgs.writeShellScript "wrapper" '' 88 exec ${pkgs.caddy}/bin/caddy run --config ${pkgs.writeTextFile { 89 name = "Caddyfile"; 90 text = '' 91 { 92 http_port 8001 93 auto_https off 94 debug 95 } 96 :8001 97 ${builtins.readFile "${pkgs.e11sync-caddyfile}"} 98 ''; 99 }} --adapter caddyfile''); 100 }; 101 e11sync-backend = { 102 type = "app"; 103 name = "e11sync-backend"; 104 program = toString (pkgs.writeShellScript "wrapper" '' 105 export E11SYNC_DATABASE_PATH=$PWD/db.sqlite3 106 exec ${pkgs.e11sync-backend}/bin/e11sync-backend 107 ''); 108 }; 109 }; 110 111 devShells.default = pkgs.mkShellNoCC { 112 packages = [ 113 ( 114 pkgs.python3.withPackages 115 (p: with p; [django geoip2 django-debug-toolbar flake8 autopep8]) 116 ) 117 pkgs.libmaxminddb 118 pkgs.dart-sass 119 120 pkgs.hugo 121 ]; 122 GEOIP_PATH = "${pkgs.geoip-mmdb}"; 123 E11SYNC_DEBUG = "1"; 124 E11SYNC_STATICFILES = "simple"; 125 LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive"; 126 inherit (self.checks.${system}.pre-commit-check) shellHook; 127 }; 128 129 formatter = pkgs.alejandra; 130 }) 131 // { 132 nixosConfigurations.vm = nixpkgs.lib.nixosSystem { 133 system = "x86_64-linux"; 134 modules = [ 135 {nixpkgs.overlays = [overlay];} 136 "${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix" 137 ./vm.nix 138 self.nixosModules.e11sync 139 ]; 140 }; 141 nixosModules.e11sync = import ./modules/e11sync geoip2-tarball; 142 143 overlays.default = overlay; 144 }; 145 }