lpk-website

Lillehammer pistolklubb website
git clone https://git.echoz.io/lpk-website.git
Log | Files | Refs | README | LICENSE

flake.nix (1868B)


      1 {
      2   inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
      3   inputs.papermod = {
      4     url = "github:adityatelange/hugo-PaperMod";
      5     flake = false;
      6   };
      7 
      8   outputs =
      9     { nixpkgs, papermod, ... }:
     10     let
     11       lib = nixpkgs.lib;
     12       systems = [
     13         "aarch64-darwin"
     14         "aarch64-linux"
     15         "x86_64-darwin"
     16         "x86_64-linux"
     17       ];
     18       argsFor = system: {
     19         pkgs = nixpkgs.legacyPackages.${system};
     20         themesDir = nixpkgs.legacyPackages.${system}.linkFarm "hugo-themes" [
     21           {
     22             name = "papermod";
     23             path = papermod;
     24           }
     25         ];
     26       };
     27       forAllSystems = f: lib.genAttrs systems (system: f (argsFor system));
     28     in
     29     {
     30       packages = forAllSystems (
     31         { pkgs, themesDir, ... }:
     32         {
     33           default = pkgs.stdenv.mkDerivation {
     34             name = "lpk-website";
     35             src = ./.;
     36             nativeBuildInputs = [ pkgs.hugo ];
     37             HUGO_THEMESDIR = themesDir;
     38             buildPhase = ''
     39               runHook preBuild
     40               hugo --minify --gc --destination $out
     41               runHook postBuild
     42             '';
     43             dontInstall = true;
     44           };
     45         }
     46       );
     47 
     48       devShells = forAllSystems (
     49         { pkgs, themesDir, ... }:
     50         {
     51           default = pkgs.mkShell {
     52             HUGO_THEMESDIR = themesDir;
     53             packages = with pkgs; [
     54               hugo
     55               (pkgs.writeShellScriptBin "dev" ''
     56                 hugo serve
     57               '')
     58             ];
     59           };
     60         }
     61       );
     62 
     63       formatter = forAllSystems (
     64         { pkgs, ... }:
     65         pkgs.treefmt.withConfig {
     66           settings = {
     67             on-unmatched = "info";
     68             formatter.nixfmt = {
     69               command = lib.getExe pkgs.nixfmt-rfc-style;
     70               includes = [ "*.nix" ];
     71             };
     72           };
     73         }
     74       );
     75     };
     76 }