aux-search/flake.nix
github-actions[bot] 7e5419d46f
flake.lock: Update (#771)
* flake.lock: Update

Flake lock file updates:

• Updated input 'nixos-infra':
    'github:NixOS/infra/0b39213973d7a4bab9f710dadb8ea1b14d206627' (2024-05-04)
  → 'github:NixOS/infra/37293ecb9e48e125b0837418711edbcaa7ffb1d0' (2024-05-23)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/63c3a29ca82437c87573e4c6919b09a24ea61b0f' (2024-05-02)
  → 'github:NixOS/nixpkgs/bfb7a882678e518398ce9a31a881538679f6f092' (2024-05-24)

* flake: pin nixpkgs for npmlock2nix

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
2024-05-31 10:58:44 +02:00

145 lines
5.4 KiB
Nix

{
description = "Code behind search.nixos.org";
nixConfig.extra-substituters = [ "https://nixos-search.cachix.org" ];
nixConfig.extra-trusted-public-keys = [ "nixos-search.cachix.org-1:1HV3YF8az4fywnH+pAd+CXFEdpTXtv9WpoivPi+H70o=" ];
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
# https://github.com/nix-community/npmlock2nix/blob/master/nix/sources.json
inputs.nixpkgs-npmlock2nix.url = "nixpkgs/c5ed8beb478a8ca035f033f659b60c89500a3034";
inputs.npmlock2nix.url = "github:nix-community/npmlock2nix";
inputs.npmlock2nix.flake = false;
inputs.nixos-infra.url = "github:NixOS/infra";
inputs.nixos-infra.flake = false;
outputs = { self
, nixpkgs
, nixpkgs-npmlock2nix
, flake-utils
, npmlock2nix
, nixos-infra
}:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
pkgsNpmlock2nix = import nixpkgs-npmlock2nix {
inherit system;
overlays = [
(self: super: {
npmlock2nix = super.callPackage npmlock2nix {};
})
];
};
lib = nixpkgs.lib;
warnToUpgradeNix = lib.warn "Please upgrade Nix to 2.7 or later.";
version = lib.fileContents ./VERSION;
nixosChannels =
let
allChannels = (import "${nixos-infra}/channels.nix").channels;
filteredChannels =
lib.filterAttrs
(n: v:
builtins.elem v.status ["rolling" "beta" "stable" "deprecated"] &&
lib.hasPrefix "nixos-" n &&
v ? variant && v.variant == "primary"
)
allChannels;
in
{
channels =
lib.mapAttrsToList
(n: v:
{
id = lib.removePrefix "nixos-" n;
status = v.status;
jobset =
builtins.concatStringsSep
"/"
(lib.init (lib.splitString "/" v.job));
branch = n;
}
)
filteredChannels;
default =
builtins.head
(builtins.sort (e1: e2: ! (builtins.lessThan e1 e2))
(builtins.map
(lib.removePrefix "nixos-")
(builtins.attrNames
(lib.filterAttrs (_: v: v.status == "stable") filteredChannels)
)
)
);
};
nixosChannelsFile = pkgs.runCommand "nixosChannels.json" {} ''
echo '${builtins.toJSON (builtins.map (c: c.id) nixosChannels.channels)}' > $out
'';
mkDevShell = { inputsFrom ? [], extraPackages ? [], extraShellHook ? "" }:
pkgs.mkShell {
inherit inputsFrom;
packages = extraPackages;
shellHook = ''
export NIXOS_CHANNELS='${builtins.toJSON nixosChannels}';
export ELASTICSEARCH_MAPPING_SCHEMA_VERSION="${version}";
'' + extraShellHook;
};
in rec {
packages.default = packages.flake-info;
packages.flake-info = import ./flake-info { inherit pkgs; };
packages.frontend = import ./frontend {
pkgs = pkgs // {
inherit (pkgsNpmlock2nix) npmlock2nix;
};
inherit nixosChannels version;
};
packages.nixosChannels = nixosChannelsFile;
devShells.default = mkDevShell {
inputsFrom = [
packages.flake-info
packages.frontend
];
extraPackages = [
pkgs.rustfmt
pkgs.yarn
];
extraShellHook = ''
export RUST_SRC_PATH="${pkgs.rustPlatform.rustLibSrc}";
export LINK_MANPAGES_PANDOC_FILTER="${packages.flake-info.LINK_MANPAGES_PANDOC_FILTER}";
export PATH=$PWD/frontend/node_modules/.bin:$PATH
'';
};
devShells.flake-info = mkDevShell {
inputsFrom = [packages.flake-info];
extraPackages = [pkgs.rustfmt];
extraShellHook = ''
export RUST_SRC_PATH="${pkgs.rustPlatform.rustLibSrc}";
export LINK_MANPAGES_PANDOC_FILTER="${packages.flake-info.LINK_MANPAGES_PANDOC_FILTER}";
'';
};
devShells.frontend = mkDevShell {
inputsFrom = [packages.frontend] ;
extraPackages = [pkgs.rustfmt pkgs.yarn];
extraShellHook = ''
export PATH=$PWD/frontend/node_modules/.bin:$PATH
rm -rf frontend/node_modules
ln -sf ${packages.frontend.yarnPkg}/libexec/${(builtins.parseDrvName packages.frontend.name).name}/node_modules frontend/
echo "========================================================"
echo "= To develop the frontend run: cd frontend && yarn dev ="
echo "========================================================"
'';
};
# XXX: for backwards compatibility
devShell = warnToUpgradeNix devShells.default;
defaultPackage = warnToUpgradeNix packages.default;
}
);
}