From 2e8711a58820fa84b4a14c6b6e754a614f22bc0e Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 21:21:00 +0100 Subject: use flakes --- flake.lock | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 21 +++++++++++++ tests/configuration.nix | 41 ++++++++++++++++++++++++ tests/run-tests.sh | 2 +- tests/vm.nix | 41 ------------------------ 5 files changed, 147 insertions(+), 42 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 tests/configuration.nix delete mode 100644 tests/vm.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..eb376cd --- /dev/null +++ b/flake.lock @@ -0,0 +1,84 @@ +{ + "nodes": { + "data": { + "inputs": { + "flake-utils": [ + "personal-webpage" + ], + "nixpkgs": [ + "personal-webpage" + ] + }, + "locked": { + "lastModified": 1668340813, + "narHash": "sha256-S3rKgiJqBGsH69zU/A3tlogMC/jpICHtSAzd/CBTVUI=", + "owner": "qaristote", + "repo": "info", + "rev": "946290203abdc6075b01a40672509bbaabd260d5", + "type": "github" + }, + "original": { + "owner": "qaristote", + "repo": "info", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1668266328, + "narHash": "sha256-+nAW+XR8nswyEnt5IkQlkrz9erTcQWBVLkhtNHxckFw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5ca8e2e9e1fa5e66a749b39261ad6bd0e07bc87f", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "personal-webpage": { + "inputs": { + "data": "data", + "flake-utils": "flake-utils", + "nixpkgs": [] + }, + "locked": { + "lastModified": 1668369630, + "narHash": "sha256-aaXUpBgOhMjDYDSsnGs28MExA4o0cXn7tV5ndfxpikU=", + "owner": "qaristote", + "repo": "webpage", + "rev": "b0cb171f641dca185cad98506d6c0e104c67dab0", + "type": "github" + }, + "original": { + "owner": "qaristote", + "repo": "webpage", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "personal-webpage": "personal-webpage" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d02d308 --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + inputs.personal-webpage = { + url = "github:qaristote/webpage"; + inputs.nixpkgs.follows = ""; + }; + + outputs = { self, nixpkgs, ... }@attrs: { + nixosConfigurations = { + hermes = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs; + modules = [ ./configuration.nix ]; + }; + hermes-test = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs; + modules = [ ./tests/configuration.nix ]; + }; + }; + }; +} diff --git a/tests/configuration.nix b/tests/configuration.nix new file mode 100644 index 0000000..e878c12 --- /dev/null +++ b/tests/configuration.nix @@ -0,0 +1,41 @@ +{ config, lib, ... }: + +let + nginxPorts = lib.concatLists + (lib.mapAttrsToList (_: cfg: (builtins.map (x: x.port) cfg.listen)) + config.services.nginx.virtualHosts); + nginxMakeLocal = port: { + listen = lib.mkForce [{ + inherit port; + addr = "0.0.0.0"; + }]; + forceSSL = lib.mkForce false; + enableACME = lib.mkForce false; + }; +in { + imports = [ ../configuration.nix ]; + + networking = lib.mkForce { + domain = "aristote.vm"; + + interfaces = { }; + defaultGateway = null; + nameservers = [ ]; + + firewall = { allowedTCPPorts = nginxPorts; }; + }; + + services.filtron.rules = lib.mkForce [ ]; + + services.nginx.virtualHosts = { + quentin = nginxMakeLocal 8080; + searx = nginxMakeLocal 8081; + money = nginxMakeLocal 8082; + rss = nginxMakeLocal 8083; + webkeydirectory = nginxMakeLocal 8084; + }; + + environment.etc."searx/secrets".text = '' + SECRET_KEY=secret_key + ''; +} diff --git a/tests/run-tests.sh b/tests/run-tests.sh index a55e282..b74a6fe 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -8,7 +8,7 @@ function cleanup { } sudo nixos-container stop hermes || exit 2 -sudo nixos-container update hermes --config-file ./vm.nix || exit 2 +sudo nixos-container update hermes --flake ..#hermes-test || exit 2 echo Starting container ... sudo nixos-container start hermes || exit 2 diff --git a/tests/vm.nix b/tests/vm.nix deleted file mode 100644 index e878c12..0000000 --- a/tests/vm.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ config, lib, ... }: - -let - nginxPorts = lib.concatLists - (lib.mapAttrsToList (_: cfg: (builtins.map (x: x.port) cfg.listen)) - config.services.nginx.virtualHosts); - nginxMakeLocal = port: { - listen = lib.mkForce [{ - inherit port; - addr = "0.0.0.0"; - }]; - forceSSL = lib.mkForce false; - enableACME = lib.mkForce false; - }; -in { - imports = [ ../configuration.nix ]; - - networking = lib.mkForce { - domain = "aristote.vm"; - - interfaces = { }; - defaultGateway = null; - nameservers = [ ]; - - firewall = { allowedTCPPorts = nginxPorts; }; - }; - - services.filtron.rules = lib.mkForce [ ]; - - services.nginx.virtualHosts = { - quentin = nginxMakeLocal 8080; - searx = nginxMakeLocal 8081; - money = nginxMakeLocal 8082; - rss = nginxMakeLocal 8083; - webkeydirectory = nginxMakeLocal 8084; - }; - - environment.etc."searx/secrets".text = '' - SECRET_KEY=secret_key - ''; -} -- cgit v1.2.3 From 9c49e96889785c4ec1fd1a398f4a8ff4306863fc Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 21:22:37 +0100 Subject: config: add hardware configuration --- config/.gitignore | 1 - config/hardware-configuration.nix | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) delete mode 100644 config/.gitignore create mode 100644 config/hardware-configuration.nix diff --git a/config/.gitignore b/config/.gitignore deleted file mode 100644 index 4c7f2b9..0000000 --- a/config/.gitignore +++ /dev/null @@ -1 +0,0 @@ -hardware-configuration.nix \ No newline at end of file diff --git a/config/hardware-configuration.nix b/config/hardware-configuration.nix new file mode 100644 index 0000000..1b79e6f --- /dev/null +++ b/config/hardware-configuration.nix @@ -0,0 +1,27 @@ +{ pkgs, lib, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; + + boot.initrd.availableKernelModules = + [ "ata_piix" "uhci_hcd" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/2b302948-5608-41c6-b54c-1c0e39ff6a58"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."root".device = + "/dev/disk/by-uuid/eaec758b-ba22-42ab-8992-e765cec9be55"; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/74d78eba-c29a-4724-8fb7-624e0a03faa5"; + fsType = "ext4"; + }; + + swapDevices = [{ device = "/swap"; }]; + +} -- cgit v1.2.3 From ab779a7476acc3a5b6dc350badd67f72f9402d6e Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 21:55:15 +0100 Subject: remove hardware configuration from test config --- config/default.nix | 1 - config/hardware-configuration.nix | 27 --------------------------- flake.nix | 2 +- hardware-configuration.nix | 27 +++++++++++++++++++++++++++ tests/configuration.nix | 4 +++- 5 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 config/hardware-configuration.nix create mode 100644 hardware-configuration.nix diff --git a/config/default.nix b/config/default.nix index 9cb4668..b35ce72 100644 --- a/config/default.nix +++ b/config/default.nix @@ -6,7 +6,6 @@ (modulesPath + "/profiles/minimal.nix") ./boot.nix ./environment.nix - ./hardware-configuration.nix ./networking.nix ./services ./users.nix diff --git a/config/hardware-configuration.nix b/config/hardware-configuration.nix deleted file mode 100644 index 1b79e6f..0000000 --- a/config/hardware-configuration.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs, lib, modulesPath, ... }: - -{ - imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; - - boot.initrd.availableKernelModules = - [ "ata_piix" "uhci_hcd" "virtio_pci" "sr_mod" "virtio_blk" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelModules = [ "kvm-amd" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = { - device = "/dev/disk/by-uuid/2b302948-5608-41c6-b54c-1c0e39ff6a58"; - fsType = "ext4"; - }; - - boot.initrd.luks.devices."root".device = - "/dev/disk/by-uuid/eaec758b-ba22-42ab-8992-e765cec9be55"; - - fileSystems."/boot" = { - device = "/dev/disk/by-uuid/74d78eba-c29a-4724-8fb7-624e0a03faa5"; - fsType = "ext4"; - }; - - swapDevices = [{ device = "/swap"; }]; - -} diff --git a/flake.nix b/flake.nix index d02d308..6ca1663 100644 --- a/flake.nix +++ b/flake.nix @@ -9,7 +9,7 @@ hermes = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = attrs; - modules = [ ./configuration.nix ]; + modules = [ ./configuration.nix ./hardware-configuration.nix ]; }; hermes-test = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..1b79e6f --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,27 @@ +{ pkgs, lib, modulesPath, ... }: + +{ + imports = [ (modulesPath + "/profiles/qemu-guest.nix") ]; + + boot.initrd.availableKernelModules = + [ "ata_piix" "uhci_hcd" "virtio_pci" "sr_mod" "virtio_blk" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = { + device = "/dev/disk/by-uuid/2b302948-5608-41c6-b54c-1c0e39ff6a58"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."root".device = + "/dev/disk/by-uuid/eaec758b-ba22-42ab-8992-e765cec9be55"; + + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/74d78eba-c29a-4724-8fb7-624e0a03faa5"; + fsType = "ext4"; + }; + + swapDevices = [{ device = "/swap"; }]; + +} diff --git a/tests/configuration.nix b/tests/configuration.nix index e878c12..73c4bfa 100644 --- a/tests/configuration.nix +++ b/tests/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ config, lib, modulesPath, ... }: let nginxPorts = lib.concatLists @@ -15,6 +15,8 @@ let in { imports = [ ../configuration.nix ]; + boot.isContainer = true; + networking = lib.mkForce { domain = "aristote.vm"; -- cgit v1.2.3 From 2ceb13adc217d5e909f40b66c40d418d1b03d4fd Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 22:58:15 +0100 Subject: tests: fix container update --- tests/run-tests.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/run-tests.sh b/tests/run-tests.sh index b74a6fe..92acdc8 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -7,7 +7,9 @@ function cleanup { sudo nixos-container stop hermes } +echo Stopping container for update ... sudo nixos-container stop hermes || exit 2 +echo Updating container ... sudo nixos-container update hermes --flake ..#hermes-test || exit 2 echo Starting container ... sudo nixos-container start hermes || exit 2 -- cgit v1.2.3 From 234e37175bedd061252a311cc3d08f4898132aae Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 22:59:21 +0100 Subject: flake: interface modules and overlays --- configuration.nix | 10 ---------- flake.lock | 32 +++++++++++++++++++------------- flake.nix | 44 ++++++++++++++++++++++++++++++++------------ tests/configuration.nix | 2 +- 4 files changed, 52 insertions(+), 36 deletions(-) delete mode 100644 configuration.nix diff --git a/configuration.nix b/configuration.nix deleted file mode 100644 index 958a63c..0000000 --- a/configuration.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ ... }: - -{ - imports = [ ./config ./modules ]; - - nixpkgs = { - overlays = - [ (final: prev: { personal = import ./pkgs { pkgs = final; }; }) ]; - }; -} diff --git a/flake.lock b/flake.lock index eb376cd..7eee262 100644 --- a/flake.lock +++ b/flake.lock @@ -3,18 +3,20 @@ "data": { "inputs": { "flake-utils": [ - "personal-webpage" + "personal-webpage", + "flake-utils" ], "nixpkgs": [ - "personal-webpage" + "personal-webpage", + "nixpkgs" ] }, "locked": { - "lastModified": 1668340813, - "narHash": "sha256-S3rKgiJqBGsH69zU/A3tlogMC/jpICHtSAzd/CBTVUI=", + "lastModified": 1668375475, + "narHash": "sha256-rp+tPVJkm8QWG48MBhk/+qblvYOmSpLamfAZkhMnyKw=", "owner": "qaristote", "repo": "info", - "rev": "946290203abdc6075b01a40672509bbaabd260d5", + "rev": "5a8c11a5fae47a8eaad7a90ac3a70020243ceb48", "type": "github" }, "original": { @@ -33,9 +35,8 @@ "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" + "id": "flake-utils", + "type": "indirect" } }, "nixpkgs": { @@ -55,15 +56,19 @@ "personal-webpage": { "inputs": { "data": "data", - "flake-utils": "flake-utils", - "nixpkgs": [] + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { - "lastModified": 1668369630, - "narHash": "sha256-aaXUpBgOhMjDYDSsnGs28MExA4o0cXn7tV5ndfxpikU=", + "lastModified": 1668375580, + "narHash": "sha256-eviU7Gx1Y1yTKsWdKQJ0fI/gA/L3MtDp5ZLbleSthzk=", "owner": "qaristote", "repo": "webpage", - "rev": "b0cb171f641dca185cad98506d6c0e104c67dab0", + "rev": "19a0c33863da3223145e4e1c1315d5332ff53df5", "type": "github" }, "original": { @@ -74,6 +79,7 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", "personal-webpage": "personal-webpage" } diff --git a/flake.nix b/flake.nix index 6ca1663..ac3ee30 100644 --- a/flake.nix +++ b/flake.nix @@ -1,21 +1,41 @@ { - inputs.personal-webpage = { - url = "github:qaristote/webpage"; - inputs.nixpkgs.follows = ""; + inputs = { + personal-webpage = { + url = "github:qaristote/webpage"; + inputs = { + nixpkgs.follows = "/nixpkgs"; + flake-utils.follows = "/flake-utils"; + }; + }; }; - outputs = { self, nixpkgs, ... }@attrs: { - nixosConfigurations = { - hermes = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = attrs; - modules = [ ./configuration.nix ./hardware-configuration.nix ]; + outputs = { self, nixpkgs, personal-webpage, flake-utils, ... }@attrs: + flake-utils.lib.eachDefaultSystem (system: { + overlays.default = final: prev: { + personal = import ./pkgs { pkgs = final; } // { + webpage = personal-webpage.defaultPackage."${system}"; + }; }; - hermes-test = nixpkgs.lib.nixosSystem { + }) // { + nixosModules.default = import ./modules; + nixosConfigurations = let system = "x86_64-linux"; specialArgs = attrs; - modules = [ ./tests/configuration.nix ]; + commonModules = [ + self.nixosModules.default + ({ ... }: { + nixpkgs.overlays = [ self.overlays."${system}".default ]; + }) + ]; + in { + hermes = nixpkgs.lib.nixosSystem { + inherit system specialArgs; + modules = commonModules ++ [ ./config ./hardware-configuration.nix ]; + }; + hermes-test = nixpkgs.lib.nixosSystem { + inherit system specialArgs; + modules = commonModules ++ [ ./tests/configuration.nix ]; + }; }; }; - }; } diff --git a/tests/configuration.nix b/tests/configuration.nix index 73c4bfa..37b043c 100644 --- a/tests/configuration.nix +++ b/tests/configuration.nix @@ -13,7 +13,7 @@ let enableACME = lib.mkForce false; }; in { - imports = [ ../configuration.nix ]; + imports = [ ../config ]; boot.isContainer = true; -- cgit v1.2.3 From 52c3597a1f281e40a400375b0e6cad3ef32a19e2 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 23:00:22 +0100 Subject: config: services: web: quentin: use new website --- config/services/web/quentin/default.nix | 2 +- pkgs/academic-webpage/default.nix | 43 --------------------------------- pkgs/default.nix | 1 - 3 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 pkgs/academic-webpage/default.nix diff --git a/config/services/web/quentin/default.nix b/config/services/web/quentin/default.nix index 8456565..f284071 100644 --- a/config/services/web/quentin/default.nix +++ b/config/services/web/quentin/default.nix @@ -3,7 +3,7 @@ { services.nginx.virtualHosts.quentin = { serverName = "quentin.${config.networking.domain}"; - locations."/".root = "${pkgs.personal.academic-webpage}"; + locations."/".root = "${pkgs.personal.webpage}"; forceSSL = true; enableACME = true; }; diff --git a/pkgs/academic-webpage/default.nix b/pkgs/academic-webpage/default.nix deleted file mode 100644 index 8310109..0000000 --- a/pkgs/academic-webpage/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ pkgs, stdenvNoCC, fetchFromGitHub, ... }: - -let wowchemy-module = name: stdenvNoCC.mkDerivation { - inherit name; - version = "v5.5.0"; - src = fetchFromGitHub { - owner = "wowchemy"; - repo = "wowchemy-hugo-themes"; - rev = "3f178a06f49582758671432d3ff8298f5d65244f"; - sha256 = "2+Pf8cBS/QEbsIjbk1VSG+OUqxHYKK7/kLajNoHvN1k="; - }; - installPhase = '' - cp -r $src/"${name}" $out - ''; - preferLocalBuild = true; - }; - wowchemy = wowchemy-module "wowchemy"; - wowchemy-cms = wowchemy-module "wowchemy-cms"; - -in stdenvNoCC.mkDerivation rec { - pname = "academic-webpage"; - version = "latest"; - - buildInputs = with pkgs; [ hugo wowchemy wowchemy-cms ]; - - src = fetchFromGitHub { - owner = "qaristote"; - repo = "academic-webpage"; - rev = "bc012418ac3621a7292bce834d2efb837281bb15"; - sha256 = "dCfTxHz98V7QOnYCP2f1QT/4UDgnUq4HnShY+q6eYxY="; - }; - - patchPhase = '' - sed -i -e "s/github.com\/wowchemy\/wowchemy-hugo-modules\/\(wowchemy[-a-z]*\)\/v5/\1/g" config/_default/config.yaml - mkdir -p themes - ln -sf "${wowchemy}" themes/wowchemy - ln -sf "${wowchemy-cms}" themes/wowchemy-cms - ''; - - installPhase = '' - hugo --destination $out - ''; -} diff --git a/pkgs/default.nix b/pkgs/default.nix index e7120f7..73848b0 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,6 +1,5 @@ { pkgs }: { - academic-webpage = pkgs.callPackage ./academic-webpage { }; filtron = pkgs.callPackage ./filtron {}; } -- cgit v1.2.3 From 5bfdfc5f55117e20893e33b397adab9c23b3622e Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 23:03:37 +0100 Subject: config: enable flakes --- config/store.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/config/store.nix b/config/store.nix index 79c4f91..38d98c5 100644 --- a/config/store.nix +++ b/config/store.nix @@ -3,6 +3,7 @@ { nix = { autoOptimiseStore = true; + experimental-features = [ "nix-command" "flakes" ]; gc = { automatic = true; dates = "daily"; -- cgit v1.2.3 From eeaf101d564adeb58532e5437ba71f228fa73e0c Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 23:19:25 +0100 Subject: config: autoUpgrade from flake --- config/store.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/store.nix b/config/store.nix index 38d98c5..cc4e15e 100644 --- a/config/store.nix +++ b/config/store.nix @@ -11,5 +11,9 @@ }; settings.max-jobs = lib.mkDefault 1; }; - system.autoUpgrade.enable = true; + system.autoUpgrade = { + enable = true; + flake = "git+file:///etc/nixos/"; + flags = [ "--update-input" "nixpkgs" "--commit-lock-file" ]; + }; } -- cgit v1.2.3 From 5440b6c3c3c240ee29436c36b66258b5fe688737 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 13 Nov 2022 23:30:53 +0100 Subject: config: enable store config --- config/default.nix | 1 + config/store.nix | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/default.nix b/config/default.nix index b35ce72..271ee4b 100644 --- a/config/default.nix +++ b/config/default.nix @@ -8,6 +8,7 @@ ./environment.nix ./networking.nix ./services + ./store.nix ./users.nix ]; diff --git a/config/store.nix b/config/store.nix index cc4e15e..8efcd5d 100644 --- a/config/store.nix +++ b/config/store.nix @@ -1,9 +1,11 @@ -{ ... }: +{ lib, ... }: { nix = { - autoOptimiseStore = true; - experimental-features = [ "nix-command" "flakes" ]; + settings = { + auto-optimise-store = true; + experimental-features = [ "nix-command" "flakes" ]; + }; gc = { automatic = true; dates = "daily"; -- cgit v1.2.3 From c4313f64675445d4da72983cbbf3b34271b5258c Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Wed, 16 Nov 2022 23:08:25 +0100 Subject: update personal webpage --- flake.lock | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 7eee262..3980289 100644 --- a/flake.lock +++ b/flake.lock @@ -12,11 +12,11 @@ ] }, "locked": { - "lastModified": 1668375475, - "narHash": "sha256-rp+tPVJkm8QWG48MBhk/+qblvYOmSpLamfAZkhMnyKw=", + "lastModified": 1668631291, + "narHash": "sha256-4c4vm/qb9PP6OTgHtEJcD2NoDwlMgYg4Z9Q6natda9o=", "owner": "qaristote", "repo": "info", - "rev": "5a8c11a5fae47a8eaad7a90ac3a70020243ceb48", + "rev": "bc83aaf07a793823676d3d94c1d50b10be9b4a57", "type": "github" }, "original": { @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668266328, - "narHash": "sha256-+nAW+XR8nswyEnt5IkQlkrz9erTcQWBVLkhtNHxckFw=", + "lastModified": 1668595402, + "narHash": "sha256-12zewsdsS3hFyWSb9x8a1pnbYOcsohvWoB6RYkMvlWE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5ca8e2e9e1fa5e66a749b39261ad6bd0e07bc87f", + "rev": "c03141948959417b580a9cbd57983af910d6727a", "type": "github" }, "original": { @@ -61,14 +61,15 @@ ], "nixpkgs": [ "nixpkgs" - ] + ], + "uncss": "uncss" }, "locked": { - "lastModified": 1668375580, - "narHash": "sha256-eviU7Gx1Y1yTKsWdKQJ0fI/gA/L3MtDp5ZLbleSthzk=", + "lastModified": 1668636351, + "narHash": "sha256-eGu4TCPtgSeCrdIlvKM/wkb7NPX83gI+R3GwMHAmwaA=", "owner": "qaristote", "repo": "webpage", - "rev": "19a0c33863da3223145e4e1c1315d5332ff53df5", + "rev": "3229cdeb36992f429a4cba6c0e0f0c0fb38db527", "type": "github" }, "original": { @@ -83,6 +84,31 @@ "nixpkgs": "nixpkgs", "personal-webpage": "personal-webpage" } + }, + "uncss": { + "inputs": { + "flake-utils": [ + "personal-webpage", + "flake-utils" + ], + "nixpkgs": [ + "personal-webpage", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1668549614, + "narHash": "sha256-1C2qBUB5Wz7DPPYR4DQi8hh2xoFA89WgEfdI2bsv4pI=", + "owner": "qaristote", + "repo": "uncss", + "rev": "0e5a335e85ec85ff6f764ea87adb5c7da83b0924", + "type": "github" + }, + "original": { + "owner": "qaristote", + "repo": "uncss", + "type": "github" + } } }, "root": "root", -- cgit v1.2.3 From b870ff99bae3de2db083f3a96dc5f74335b1c529 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Wed, 16 Nov 2022 23:25:05 +0100 Subject: update personal webpage --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 3980289..9bc7178 100644 --- a/flake.lock +++ b/flake.lock @@ -65,11 +65,11 @@ "uncss": "uncss" }, "locked": { - "lastModified": 1668636351, - "narHash": "sha256-eGu4TCPtgSeCrdIlvKM/wkb7NPX83gI+R3GwMHAmwaA=", + "lastModified": 1668637413, + "narHash": "sha256-Uj/aYwlLRV8ZQqO7M8ZCkrTsMXM04+ByQktUQHiJpiM=", "owner": "qaristote", "repo": "webpage", - "rev": "3229cdeb36992f429a4cba6c0e0f0c0fb38db527", + "rev": "4098a8323a2dfbb498e1e59bef417b48b1034775", "type": "github" }, "original": { -- cgit v1.2.3 From 0652fc1fcc72047db640453e09aa36e134567c07 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 20 Nov 2022 18:02:47 +0100 Subject: services: web: quentin: fix picture --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 9bc7178..b19b16f 100644 --- a/flake.lock +++ b/flake.lock @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668595402, - "narHash": "sha256-12zewsdsS3hFyWSb9x8a1pnbYOcsohvWoB6RYkMvlWE=", + "lastModified": 1668912770, + "narHash": "sha256-Nzt7ALUl5PrUAYIH8aRbj+njkJZVQ4VQBkWx+qQvqyM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c03141948959417b580a9cbd57983af910d6727a", + "rev": "862277ac9d34273cd953f42061e23d488d6b7e8b", "type": "github" }, "original": { @@ -65,11 +65,11 @@ "uncss": "uncss" }, "locked": { - "lastModified": 1668637413, - "narHash": "sha256-Uj/aYwlLRV8ZQqO7M8ZCkrTsMXM04+ByQktUQHiJpiM=", + "lastModified": 1668963583, + "narHash": "sha256-0zFZ9AFQFo9ef7iOQeRS7vp1gIanBkl4+0PHT3zcR68=", "owner": "qaristote", "repo": "webpage", - "rev": "4098a8323a2dfbb498e1e59bef417b48b1034775", + "rev": "3b58f293f93dabf06f950f5d85e1dc053f622774", "type": "github" }, "original": { -- cgit v1.2.3 From 5260c8daee219adab6188b794d643c63b1617379 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 01:14:01 +0100 Subject: services: web: rss: add Mubi bridge --- config/services/web/rss/MubiBridge.php | 68 ++++++++++++++++++++++++++++++++++ config/services/web/rss/default.nix | 11 ++++-- 2 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 config/services/web/rss/MubiBridge.php diff --git a/config/services/web/rss/MubiBridge.php b/config/services/web/rss/MubiBridge.php new file mode 100644 index 0000000..f1c24dc --- /dev/null +++ b/config/services/web/rss/MubiBridge.php @@ -0,0 +1,68 @@ +primary_film_group)) { + return $obj->primary_film_group->description_html . '
'; + } else { + return ''; + } +} + +class MubiBridge extends XPathAbstract { + const NAME = 'Mubi Bridge'; + const URI = 'https://mubi.com'; + const DESCRIPTION = 'Mubi\'s film of the day.'; + const MAINTAINER = 'Quentin Aristote'; + const CACHE_TIMEOUT = 21600; // 6h + + const PARAMETERS = [ + '' => [ + 'language' => [ + 'name' => 'Language', + 'type' => 'string', + 'required' => 'true', + 'exampleValue' => 'en / de / es / fr / it / nl / pt / tr' + ] + ] + ]; + + public function getIcon() { + return 'https://mubi.com/favicon.ico'; + } + + public function getUri() { + return self::URI . '/' . $this->getInput('language') . '/film-of-the-day'; + } + + public function collectData() { + $dataJsonStr = extractFromDelimiters( + getSimpleHTMLDOMCached($this->getUri()), + ''); + $data = json_decode($dataJsonStr)->props->initialState; + foreach ($data->filmProgramming->filmProgrammings as $filmProgramming) { + $id = $filmProgramming->filmId; + $film = $data->film->films->{$id}; + $item = [ + 'title' => $filmProgramming->email_subject, + 'uri' => 'https://mubi.com/' . $this->getInput('language') . '/films/' . $film->slug, + 'timestamp' => strtotime($filmProgramming->available_at), + 'author' => $film->directors[0]->name, + 'content' => ( + $filmProgramming->our_take_html . '
' . + tryGetDescription($filmProgramming) . + $film->short_synopsis_html . '
' . + $film->default_editorial_html + ), + 'enclosures' => [ + $film->stills->standard, + $film->trailer_url + ], + 'categories' => $film->genres, + 'uid' => $id . $filmProgramming->available_at + ]; + $this->items[] = $item; + } + } +} diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index 4d7dd18..776402a 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -2,12 +2,15 @@ let cfg = config.services.rss-bridge; - debug = false; + debug = true; rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: oldAttrs // { installPhase = oldAttrs.installPhase + '' - ln -sf ${./ParisJazzClubBridge.php} $out/bridges/ParisJazzClubBridge.php - ln -sf ${./MaisonDeLaRadioBridge.php} $out/bridges/MaisonDeLaRadioBridge.php + pushd $out/bridges + ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php + ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php + ln -sf ${./MubiBridge.php} MubiBridge.php + popd '' + lib.optionalString debug '' touch $out/DEBUG ''; @@ -15,7 +18,7 @@ let in { services.rss-bridge = { enable = true; - whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" ]; + whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "Mubi" ]; virtualHost = "rss"; }; -- cgit v1.2.3 From b3e31416ccf7cacbac4d2f4efef7dd28fe3ec493 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 01:18:39 +0100 Subject: services: web: rss: disable debug mode --- config/services/web/rss/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index 776402a..8975d14 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -2,7 +2,7 @@ let cfg = config.services.rss-bridge; - debug = true; + debug = false; rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: oldAttrs // { installPhase = oldAttrs.installPhase + '' -- cgit v1.2.3 From b35b47155a6989f7644cbb7be82a388c1840a0f6 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 01:26:00 +0100 Subject: services: web: rss: Mubi: fix language parameter --- config/services/web/rss/MubiBridge.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/services/web/rss/MubiBridge.php b/config/services/web/rss/MubiBridge.php index f1c24dc..992f463 100644 --- a/config/services/web/rss/MubiBridge.php +++ b/config/services/web/rss/MubiBridge.php @@ -20,9 +20,9 @@ class MubiBridge extends XPathAbstract { '' => [ 'language' => [ 'name' => 'Language', - 'type' => 'string', - 'required' => 'true', - 'exampleValue' => 'en / de / es / fr / it / nl / pt / tr' + 'type' => 'text', + 'exampleValue' => 'en / de / es / fr / it / nl / pt / tr', + 'defaultValue' => 'en' ] ] ]; -- cgit v1.2.3 From 0c0affb59873dd265719a7293dfde6f76495c612 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 13:12:19 +0100 Subject: services: web: rss: Mubi: replace with What's On Mubi --- config/services/web/rss/MubiBridge.php | 68 --------------------------- config/services/web/rss/WhatsOnMubiBridge.php | 49 +++++++++++++++++++ config/services/web/rss/default.nix | 4 +- 3 files changed, 51 insertions(+), 70 deletions(-) delete mode 100644 config/services/web/rss/MubiBridge.php create mode 100644 config/services/web/rss/WhatsOnMubiBridge.php diff --git a/config/services/web/rss/MubiBridge.php b/config/services/web/rss/MubiBridge.php deleted file mode 100644 index 992f463..0000000 --- a/config/services/web/rss/MubiBridge.php +++ /dev/null @@ -1,68 +0,0 @@ -primary_film_group)) { - return $obj->primary_film_group->description_html . '
'; - } else { - return ''; - } -} - -class MubiBridge extends XPathAbstract { - const NAME = 'Mubi Bridge'; - const URI = 'https://mubi.com'; - const DESCRIPTION = 'Mubi\'s film of the day.'; - const MAINTAINER = 'Quentin Aristote'; - const CACHE_TIMEOUT = 21600; // 6h - - const PARAMETERS = [ - '' => [ - 'language' => [ - 'name' => 'Language', - 'type' => 'text', - 'exampleValue' => 'en / de / es / fr / it / nl / pt / tr', - 'defaultValue' => 'en' - ] - ] - ]; - - public function getIcon() { - return 'https://mubi.com/favicon.ico'; - } - - public function getUri() { - return self::URI . '/' . $this->getInput('language') . '/film-of-the-day'; - } - - public function collectData() { - $dataJsonStr = extractFromDelimiters( - getSimpleHTMLDOMCached($this->getUri()), - ''); - $data = json_decode($dataJsonStr)->props->initialState; - foreach ($data->filmProgramming->filmProgrammings as $filmProgramming) { - $id = $filmProgramming->filmId; - $film = $data->film->films->{$id}; - $item = [ - 'title' => $filmProgramming->email_subject, - 'uri' => 'https://mubi.com/' . $this->getInput('language') . '/films/' . $film->slug, - 'timestamp' => strtotime($filmProgramming->available_at), - 'author' => $film->directors[0]->name, - 'content' => ( - $filmProgramming->our_take_html . '
' . - tryGetDescription($filmProgramming) . - $film->short_synopsis_html . '
' . - $film->default_editorial_html - ), - 'enclosures' => [ - $film->stills->standard, - $film->trailer_url - ], - 'categories' => $film->genres, - 'uid' => $id . $filmProgramming->available_at - ]; - $this->items[] = $item; - } - } -} diff --git a/config/services/web/rss/WhatsOnMubiBridge.php b/config/services/web/rss/WhatsOnMubiBridge.php new file mode 100644 index 0000000..4cf7718 --- /dev/null +++ b/config/services/web/rss/WhatsOnMubiBridge.php @@ -0,0 +1,49 @@ + [ + 'country' => [ + 'name' => 'Country', + 'type' => 'text', + 'exampleValue' => 'fr', + 'defaultValue' => 'fr', + ] + ] + ]; + + const XPATH_EXPRESSION_ITEM = '//div[@class="film"]'; + const XPATH_EXPRESSION_ITEM_TITLE = './/h2'; + const XPATH_EXPRESSION_ITEM_CONTENT = './/div[@class="film_details flex flex-col flex-1"]'; + const XPATH_EXPRESSION_ITEM_URI = './/a[@class="relative film_thumbnail"]/@href'; + const XPATH_EXPRESSION_ITEM_AUTHOR = './@data-directors'; + const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/p[@class="hidden film-expires"]'; + const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/a[@class="relative film_thumbnail"]/img/@src'; + const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[@class="film_details flex flex-col flex-1"]//div[@class="mt-3 flex flex-wrap"]'; + + public function getSourceUrl() { + return self::URI . '&showing=' . $this->getInput('country'); + } + + public function getIcon() { + return 'https://whatsonmubi.com/favicon.ico'; + } + + protected function formatItemTimestamp($value) { + return strtotime('today +' . $value); + } + + protected function formatItemContent($value) { + $text = preg_replace("/\s{2}\s+/", "\n", $value); + $lines = array_map("trim", explode("\n", $text)); + $title = $lines[0]; + $director = $lines[1]; + return $director . ' ' . $title; + } +} diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index 8975d14..2c5d515 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -9,7 +9,7 @@ let pushd $out/bridges ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php - ln -sf ${./MubiBridge.php} MubiBridge.php + ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php popd '' + lib.optionalString debug '' touch $out/DEBUG @@ -18,7 +18,7 @@ let in { services.rss-bridge = { enable = true; - whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "Mubi" ]; + whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "WhatsOnMubi" ]; virtualHost = "rss"; }; -- cgit v1.2.3 From efa28a3baa12cac85f4cfc8665f1cf8762b9d7ee Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 16:28:24 +0100 Subject: services: web: rss: add fip bridge --- config/services/web/rss/FipAlbumsBridge.php | 41 +++++++++++++++++++++++++++++ config/services/web/rss/default.nix | 5 ++-- 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 config/services/web/rss/FipAlbumsBridge.php diff --git a/config/services/web/rss/FipAlbumsBridge.php b/config/services/web/rss/FipAlbumsBridge.php new file mode 100644 index 0000000..dfc3930 --- /dev/null +++ b/config/services/web/rss/FipAlbumsBridge.php @@ -0,0 +1,41 @@ + [ + 'category' => [ + 'name' => 'Category', + 'type' => 'text', + 'description' => 'See examples for available options.', + 'exampleValue' => 'can be empty, "selections" or "album-jazz-de-la-semaine"' + ] + ] + ]; + + const XPATH_EXPRESSION_ITEM = '//div[@class="Card Basic list squaredVisual"]'; + const XPATH_EXPRESSION_ITEM_TITLE = './/a/@title'; + const XPATH_EXPRESSION_ITEM_CONTENT = './div[1]'; + const XPATH_EXPRESSION_ITEM_URI = './/a/@href'; + const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[@class="CardDetails fullWidth"]/div[2]'; + const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/time/@datetime'; + const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/img/@src'; + const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[@class="CardDetails fullWidth"]/div[3]'; + + public function getSourceUrl() { + return self::URI . $this->getInput('category'); + } + + public function getIcon() { + return 'https://www.radiofrance.fr/dist/favicons/fip/favicon.png'; + } + + protected function formatItemTimestamp($value) { + return strtotime('today +' . $value); + } +} diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index 2c5d515..18a6763 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -2,13 +2,14 @@ let cfg = config.services.rss-bridge; - debug = false; + debug = true; rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: oldAttrs // { installPhase = oldAttrs.installPhase + '' pushd $out/bridges ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php + ln -sf ${./FipAlbumsBridge.php} FipAlbumsBridge.php ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php popd '' + lib.optionalString debug '' @@ -18,7 +19,7 @@ let in { services.rss-bridge = { enable = true; - whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "WhatsOnMubi" ]; + whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "FipAlbumsBridge" "WhatsOnMubi" ]; virtualHost = "rss"; }; -- cgit v1.2.3 From 4a24f168e3fb44073237d9aca95a97e77bdefa3c Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 17:41:34 +0100 Subject: services: web: rss: make configuration into a module --- config/services/web/rss/default.nix | 53 ++++++++++++++++++--------- modules/default.nix | 1 + modules/rss-bridge.nix | 71 +++++++++++++++++++++++++++++++++++++ tests/configuration.nix | 2 ++ 4 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 modules/rss-bridge.nix diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index 18a6763..acc9331 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -2,31 +2,52 @@ let cfg = config.services.rss-bridge; - debug = true; - rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: - oldAttrs // { - installPhase = oldAttrs.installPhase + '' - pushd $out/bridges - ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php - ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php - ln -sf ${./FipAlbumsBridge.php} FipAlbumsBridge.php - ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php - popd - '' + lib.optionalString debug '' - touch $out/DEBUG - ''; - }); + # debug = true; + # rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: + # oldAttrs // { + # installPhase = oldAttrs.installPhase + '' + # pushd $out/bridges + # ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php + # ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php + # ln -sf ${./FipAlbumsBridge.php} FipAlbumsBridge.php + # ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php + # popd + # '' + lib.optionalString debug '' + # touch $out/DEBUG + # ''; + # }); in { services.rss-bridge = { enable = true; - whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "FipAlbumsBridge" "WhatsOnMubi" ]; + # whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "FipAlbumsBridge" "WhatsOnMubi" ]; + extraBridges = [ + # Music + { + name = "FipAlbums"; + source = ./FipAlbumsBridge.php; + } + ## Concerts + { + name = "ParisJazzClub"; + source = ./ParisJazzClubBridge.php; + } + { + name = "MaisonDeLaRadio"; + source = ./MaisonDeLaRadioBridge.php; + } + # Cinema + { + name = "WhatsOnMubi"; + source = ./WhatsOnMubiBridge.php; + } + ]; virtualHost = "rss"; }; services.nginx = lib.mkIf (cfg.virtualHost != null) { virtualHosts.${cfg.virtualHost} = { serverName = "rss.${config.networking.domain}"; - root = lib.mkForce "${rss-bridge}"; + # root = lib.mkForce "${rss-bridge}"; forceSSL = true; enableACME = true; }; diff --git a/modules/default.nix b/modules/default.nix index d09a8c0..95f75b4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -3,5 +3,6 @@ { imports = [ ./filtron.nix + ./rss-bridge.nix ]; } diff --git a/modules/rss-bridge.nix b/modules/rss-bridge.nix new file mode 100644 index 0000000..c7aaf05 --- /dev/null +++ b/modules/rss-bridge.nix @@ -0,0 +1,71 @@ +{ config, lib, pkgs, ... }: + +with lib; +let + cfg = config.services.rss-bridge; + rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: + oldAttrs // { + installPhase = oldAttrs.installPhase + '' + pushd $out/bridges + ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php + ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php + ln -sf ${./FipAlbumsBridge.php} FipAlbumsBridge.php + ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php + popd + '' + lib.optionalString debug '' + touch $out/DEBUG + ''; + }); +in { + options.services.rss-bridge = { + package = mkOption { + type = types.package; + description = "Which derivation to use."; + default = pkgs.rss-bridge; + defaultText = literalExample "pkgs.rss-bridge"; + }; + debug = mkEnableOption "debug mode"; + extraBridges = mkOption { + type = types.listOf (types.submodule { + options = { + name = mkOption { + type = types.strMatching "[a-zA-Z0-9]*"; + description = '' + The name of the bridge. + It need not include 'Bridge' at the end, unlike required in RSS-Bridge. + ''; + example = "SomeAppWithANewsletter"; + }; + source = mkOption { + type = types.path; + description = '' + The path to a file whose contents is the PHP sourcecode of the bridge. + See also the RSS-Bridge documentation: https://rss-bridge.github.io/rss-bridge/Bridge_API/index.html. + ''; + }; + }; + }); + default = [ ]; + description = '' + A list of additional bridges that aren't already included in RSS-Bridge. + These bridges are automatically whitelisted''; + }; + }; + + config.services.rss-bridge.whitelist = + map (bridge: bridge.name) cfg.extraBridges; + config.services.nginx = mkIf (cfg.virtualHost != null) { + virtualHosts.${cfg.virtualHost}.root = mkIf (cfg.extraBridges != [ ]) + (mkForce (pkgs.runCommand "rss-bridge" { } ('' + mkdir -p $out/bridges + cp -r ${cfg.package}/* $out/ + pushd $out/bridges + '' + concatStringsSep "\n" + (map (bridge: ''ln -sf ${bridge.source} "${bridge.name}Bridge.php"'') + cfg.extraBridges) + '' + popd + '' + lib.optionalString cfg.debug '' + touch $out/DEBUG + ''))); + }; +} diff --git a/tests/configuration.nix b/tests/configuration.nix index 37b043c..a1ccf52 100644 --- a/tests/configuration.nix +++ b/tests/configuration.nix @@ -29,6 +29,8 @@ in { services.filtron.rules = lib.mkForce [ ]; + services.rss-bridge.debug = true; + services.nginx.virtualHosts = { quentin = nginxMakeLocal 8080; searx = nginxMakeLocal 8081; -- cgit v1.2.3 From dc278c9ef8377e2405698f17c0406c393465a65a Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 17:46:39 +0100 Subject: services: web: rss: remove extra comments --- config/services/web/rss/default.nix | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index acc9331..a6da155 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -2,24 +2,9 @@ let cfg = config.services.rss-bridge; - # debug = true; - # rss-bridge = pkgs.rss-bridge.overrideAttrs (oldAttrs: - # oldAttrs // { - # installPhase = oldAttrs.installPhase + '' - # pushd $out/bridges - # ln -sf ${./ParisJazzClubBridge.php} ParisJazzClubBridge.php - # ln -sf ${./MaisonDeLaRadioBridge.php} MaisonDeLaRadioBridge.php - # ln -sf ${./FipAlbumsBridge.php} FipAlbumsBridge.php - # ln -sf ${./WhatsOnMubiBridge.php} WhatsOnMubiBridge.php - # popd - # '' + lib.optionalString debug '' - # touch $out/DEBUG - # ''; - # }); in { services.rss-bridge = { enable = true; - # whitelist = [ "ParisJazzClub" "MaisonDeLaRadio" "FipAlbumsBridge" "WhatsOnMubi" ]; extraBridges = [ # Music { @@ -47,7 +32,6 @@ in { services.nginx = lib.mkIf (cfg.virtualHost != null) { virtualHosts.${cfg.virtualHost} = { serverName = "rss.${config.networking.domain}"; - # root = lib.mkForce "${rss-bridge}"; forceSSL = true; enableACME = true; }; -- cgit v1.2.3 From d051993c310b11be05c9196db1a5e151b4009bcd Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 17:57:13 +0100 Subject: modules: rss-bridge: fix linking of extra bridges --- modules/rss-bridge.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/rss-bridge.nix b/modules/rss-bridge.nix index c7aaf05..7acc6a5 100644 --- a/modules/rss-bridge.nix +++ b/modules/rss-bridge.nix @@ -60,12 +60,12 @@ in { mkdir -p $out/bridges cp -r ${cfg.package}/* $out/ pushd $out/bridges - '' + concatStringsSep "\n" - (map (bridge: ''ln -sf ${bridge.source} "${bridge.name}Bridge.php"'') - cfg.extraBridges) + '' - popd - '' + lib.optionalString cfg.debug '' - touch $out/DEBUG - ''))); + '' + concatStrings (map (bridge: '' + ln -sf ${bridge.source} "${bridge.name}Bridge.php" + '') cfg.extraBridges) + '' + popd + '' + lib.optionalString cfg.debug '' + touch $out/DEBUG + ''))); }; } -- cgit v1.2.3 From 7edddf91dd8889c2aee8279a35400a19340c78d1 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 18:02:05 +0100 Subject: flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/862277ac9d34273cd953f42061e23d488d6b7e8b' (2022-11-20) → 'github:NixOS/nixpkgs/b45ec953794bb07922f0468152ad1ebaf8a084b3' (2022-11-27) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index b19b16f..a98c43c 100644 --- a/flake.lock +++ b/flake.lock @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1668912770, - "narHash": "sha256-Nzt7ALUl5PrUAYIH8aRbj+njkJZVQ4VQBkWx+qQvqyM=", + "lastModified": 1669535121, + "narHash": "sha256-koZLM7oWVGrjyHnYDo7/w5qlmUn9UZUKSFNfmIjueE8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "862277ac9d34273cd953f42061e23d488d6b7e8b", + "rev": "b45ec953794bb07922f0468152ad1ebaf8a084b3", "type": "github" }, "original": { -- cgit v1.2.3 From ed163a6c11d9dc291f074a6d27681617c964a97d Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 18:05:34 +0100 Subject: remove extra whitespace --- modules/rss-bridge.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rss-bridge.nix b/modules/rss-bridge.nix index 7acc6a5..7c0d349 100644 --- a/modules/rss-bridge.nix +++ b/modules/rss-bridge.nix @@ -59,7 +59,7 @@ in { (mkForce (pkgs.runCommand "rss-bridge" { } ('' mkdir -p $out/bridges cp -r ${cfg.package}/* $out/ - pushd $out/bridges + pushd $out/bridges '' + concatStrings (map (bridge: '' ln -sf ${bridge.source} "${bridge.name}Bridge.php" '') cfg.extraBridges) + '' -- cgit v1.2.3 From 58db771dfbbf71a471ed92b324d2cbe16a1e0b12 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 27 Nov 2022 20:00:23 +0100 Subject: services: web: rss: add paris-cine.info bridge --- config/services/web/rss/ParisCineInfoBridge.php | 98 +++++++++++++++++++++++++ config/services/web/rss/default.nix | 7 +- 2 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 config/services/web/rss/ParisCineInfoBridge.php diff --git a/config/services/web/rss/ParisCineInfoBridge.php b/config/services/web/rss/ParisCineInfoBridge.php new file mode 100644 index 0000000..5e418b4 --- /dev/null +++ b/config/services/web/rss/ParisCineInfoBridge.php @@ -0,0 +1,98 @@ + [ + // TODO add an option for choosing the reviewer + 'card' => [ + 'name' => 'Card', + 'type' => 'text', + 'title' => 'Fidelity / subscription card.', + 'exampleValue' => 'ugc', + 'defaultValue' => 'all' + ], + 'dayid' => [ + 'name' => 'Day of the week', + 'type' => 'text', + 'title' => 'Comma-separated list of integers (0 means everyday, 1 means Sunday, etc.)/', + 'exampleValue' => '1,3,6', + 'defaultValue' => '0' + ], + 'time' => [ + 'name' => 'Time of day', + 'type' => 'text', + 'title' => 'Morning (8AM-12AM), Afternoon (12AM-18PM), Evening (18PM-12PM).', + 'exampleValue' => 'soir', + 'defaultValue' => 'all' + ], + 'addr' => [ + 'name' => 'Location', + 'type' => 'text', + 'title' => 'Comma-separated list of districts or cities.', + 'exampleValue' => '13e,Châtillon', + 'defaultValue' => 'Paris' + ], + 'cine' => [ + 'name' => 'Theater', + 'type' => 'text', + 'title' => 'ID of a movie theater.', + 'exampleValue' => 'C0150', + ], + 'format' => [ + 'name' => 'Format', + 'type' => 'text', + 'title' => 'Movie format.', + 'exampleValue' => '3D' + ] + ] + ]; + + public function getSourceUrl() { + $query = ''; + foreach(self::PARAMETERS['Filters'] as $param => $val) { + $value = $this->getInput($param); + if ($value != '') { + $query = $query . 'sel' . $param . '=' . $value . '&'; + } + } + $selday = ['week', 'dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'][$this->getInput('dayid')]; + return self::URI . 'get_pcimovies.php?' . $query . 'selday=' . $selday; + } + + private function fetchData() { + return json_decode(getSimpleHTMLDOMCached($this->getSourceUrl()))->data; + } + + public function getIcon() { + return 'https://paris-cine.info/resources/img/favicon-16x16.png'; + } + + public function collectData() { + $data = $this->fetchData(); + foreach($data as $film) { + $item = [ + 'uri' => str_replace('\\/', '/', $film->sc_url), + 'title' => $film->title, + 'timestamp' => str_replace('/', '-', $film->released), + 'author' => $film->dir, + 'content' => ( + $film->year . ' - ' . + 'with ' . str_replace(',', ', ', $film->actors) . ' - ' . + $film->duration . ' - ' . + 'SC: ' . $film->sc_rating . '/10 - ' . + 'IMDB: ' . $film->imdbr . '/10' . ' ' + ), + 'enclosures' => [ $film->poster_url ], + 'categories' => explode(',', $film->genre), + 'id' => $film->id + ]; + $this->items[] = $item; + } + } +} diff --git a/config/services/web/rss/default.nix b/config/services/web/rss/default.nix index a6da155..f2b667b 100644 --- a/config/services/web/rss/default.nix +++ b/config/services/web/rss/default.nix @@ -1,7 +1,6 @@ { config, lib, pkgs, ... }: -let - cfg = config.services.rss-bridge; +let cfg = config.services.rss-bridge; in { services.rss-bridge = { enable = true; @@ -25,6 +24,10 @@ in { name = "WhatsOnMubi"; source = ./WhatsOnMubiBridge.php; } + { + name = "ParisCineInfo"; + source = ./ParisCineInfoBridge.php; + } ]; virtualHost = "rss"; }; -- cgit v1.2.3 From 3221a771ee11e18c6cb3eb2a654626259ab134c1 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 4 Dec 2022 13:09:47 +0100 Subject: services: web: rss: fip: debug xpaths --- config/services/web/rss/FipAlbumsBridge.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/services/web/rss/FipAlbumsBridge.php b/config/services/web/rss/FipAlbumsBridge.php index dfc3930..b8ec64d 100644 --- a/config/services/web/rss/FipAlbumsBridge.php +++ b/config/services/web/rss/FipAlbumsBridge.php @@ -18,14 +18,14 @@ class FipAlbumsBridge extends XPathAbstract { ] ]; - const XPATH_EXPRESSION_ITEM = '//div[@class="Card Basic list squaredVisual"]'; + const XPATH_EXPRESSION_ITEM = '//div[starts-with(@class, "CardAlbum ")]'; const XPATH_EXPRESSION_ITEM_TITLE = './/a/@title'; - const XPATH_EXPRESSION_ITEM_CONTENT = './div[1]'; + const XPATH_EXPRESSION_ITEM_CONTENT = './/img/@alt'; const XPATH_EXPRESSION_ITEM_URI = './/a/@href'; - const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[@class="CardDetails fullWidth"]/div[2]'; + const XPATH_EXPRESSION_ITEM_AUTHOR = './/div[starts-with(@class, "CardAlbum-details ")]/div[2]'; const XPATH_EXPRESSION_ITEM_TIMESTAMP = './/time/@datetime'; const XPATH_EXPRESSION_ITEM_ENCLOSURES = './/img/@src'; - const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[@class="CardDetails fullWidth"]/div[3]'; + const XPATH_EXPRESSION_ITEM_CATEGORIES = './/div[starts-with(@class, "CardDetails-label ")]/span[2]'; public function getSourceUrl() { return self::URI . $this->getInput('category'); -- cgit v1.2.3 From 3362029ceb7076c9351ffac34133669faf661ac1 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 4 Dec 2022 13:11:10 +0100 Subject: services: web: searx: engines: update to v1.1.0 --- config/services/web/searx/searx/engines.nix | 24 +----------------------- tests/run-tests.sh | 1 - 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/config/services/web/searx/searx/engines.nix b/config/services/web/searx/searx/engines.nix index 5e4609a..76f0ca8 100644 --- a/config/services/web/searx/searx/engines.nix +++ b/config/services/web/searx/searx/engines.nix @@ -54,7 +54,7 @@ in { # files "btdigg" # images - "ccengine" + "openverse" "bing images" "library of congress" "qwant images" @@ -96,28 +96,6 @@ in { results = "HTML"; }; } - { # Emojipedia - name = "emojipedia"; - engine = "xpath"; - search_url = makeSearchUrl { - baseUrl = "https://emojipedia.org/search/"; - queryKeyword = "q"; - }; - results_xpath = ''//ol[@class="search-results"]/li/h2''; - url_xpath = "./a/@href"; - title_xpath = "./a"; - content_xpath = "../p"; - shortcut = "emoji"; - disabled = true; - about = { - website = "https://emojipedia.org/"; - wikidata_id = "Q22908129"; - official_api_documentation = ""; - use_official_api = false; - require_api_key = false; - results = "HTML"; - }; - } { name = "nlab"; engine = "xpath"; diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 92acdc8..7842dc6 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -42,7 +42,6 @@ echo echo Checking custom Searx engines : declare -A QUERIES QUERIES[alternativeto]=Searx -QUERIES[emojipedia]='Thinking%20Face' QUERIES[nlab]='Kan%20extension' QUERIES[wikipediafr]=Paris QUERIES[wikipediaen]=Paris -- cgit v1.2.3 From f6c306074d0c70fd2ad20c5182f557359e611378 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sun, 4 Dec 2022 13:18:18 +0100 Subject: flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/b45ec953794bb07922f0468152ad1ebaf8a084b3' (2022-11-27) → 'github:NixOS/nixpkgs/813836d64fa57285d108f0dbf2356457ccd304e3' (2022-12-03) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index a98c43c..cb34263 100644 --- a/flake.lock +++ b/flake.lock @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1669535121, - "narHash": "sha256-koZLM7oWVGrjyHnYDo7/w5qlmUn9UZUKSFNfmIjueE8=", + "lastModified": 1670086663, + "narHash": "sha256-hT8C8AQB74tdoCPwz4nlJypLMD7GI2F5q+vn+VE/qQk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b45ec953794bb07922f0468152ad1ebaf8a084b3", + "rev": "813836d64fa57285d108f0dbf2356457ccd304e3", "type": "github" }, "original": { -- cgit v1.2.3 From e09b2af5fecdfad696ce58436df5076328759c0a Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Sat, 17 Dec 2022 18:41:33 +0100 Subject: update webpage --- flake.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index cb34263..d5d6fa0 100644 --- a/flake.lock +++ b/flake.lock @@ -12,11 +12,11 @@ ] }, "locked": { - "lastModified": 1668631291, - "narHash": "sha256-4c4vm/qb9PP6OTgHtEJcD2NoDwlMgYg4Z9Q6natda9o=", + "lastModified": 1671297777, + "narHash": "sha256-kvCzzOupvgGyO3Q/0cpGPgDYEdj8g6MVCH4Mlt/e56k=", "owner": "qaristote", "repo": "info", - "rev": "bc83aaf07a793823676d3d94c1d50b10be9b4a57", + "rev": "c91a58357700a466aee5135767535136c878e009", "type": "github" }, "original": { @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1670086663, - "narHash": "sha256-hT8C8AQB74tdoCPwz4nlJypLMD7GI2F5q+vn+VE/qQk=", + "lastModified": 1671249438, + "narHash": "sha256-5e+CcnbZA3/i2BRXbnzRS52Ly67MUNdZR+Zpbb2C65k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "813836d64fa57285d108f0dbf2356457ccd304e3", + "rev": "067bfc6c90a301572cec7da48f09c447a9a8eae0", "type": "github" }, "original": { @@ -65,11 +65,11 @@ "uncss": "uncss" }, "locked": { - "lastModified": 1668963583, - "narHash": "sha256-0zFZ9AFQFo9ef7iOQeRS7vp1gIanBkl4+0PHT3zcR68=", + "lastModified": 1671298845, + "narHash": "sha256-lFVBXth57Pn6QIN+vPvFR87UxWJ1HFXarHalDvjWrR4=", "owner": "qaristote", "repo": "webpage", - "rev": "3b58f293f93dabf06f950f5d85e1dc053f622774", + "rev": "334d3318b16d765dc10a537be841240986aeea04", "type": "github" }, "original": { -- cgit v1.2.3 From 9bde3c4624eb916bafcf9a18792edb42e3a25a17 Mon Sep 17 00:00:00 2001 From: Quentin Aristote Date: Tue, 20 Dec 2022 22:29:23 +0100 Subject: searx: engines: wikipedia: fix xpath and test --- config/services/web/searx/searx/engines.nix | 6 +++--- tests/run-tests.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/services/web/searx/searx/engines.nix b/config/services/web/searx/searx/engines.nix index 76f0ca8..5256c27 100644 --- a/config/services/web/searx/searx/engines.nix +++ b/config/services/web/searx/searx/engines.nix @@ -29,9 +29,9 @@ let extraParameters = { fulltext = 1; }; }; results_xpath = ''//ul[@class="mw-search-results"]/li''; - url_xpath = ''./div[@class="mw-search-result-heading"]/a/@href''; - title_xpath = ''./div[@class="mw-search-result-heading"]/a''; - content_xpath = ''./div[@class="searchresult"]''; + url_xpath = ''.//div[@class="mw-search-result-heading"]/a/@href''; + title_xpath = ''.//div[@class="mw-search-result-heading"]/a/@title''; + content_xpath = ''.//div[@class="searchresult"]''; shortcut = "w${lang}"; categories = "general"; disabled = true; diff --git a/tests/run-tests.sh b/tests/run-tests.sh index 7842dc6..705f28d 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -43,8 +43,8 @@ echo Checking custom Searx engines : declare -A QUERIES QUERIES[alternativeto]=Searx QUERIES[nlab]='Kan%20extension' -QUERIES[wikipediafr]=Paris -QUERIES[wikipediaen]=Paris +QUERIES[wfr]=Paris +QUERIES[wen]=Paris for ENGINE in "${!QUERIES[@]}" do echo Checking engine $ENGINE ... -- cgit v1.2.3