2020-06-18 22:41:01 +00:00
|
|
|
{
|
|
|
|
description = "Code behind search.nixos.org";
|
|
|
|
|
2022-04-07 21:36:07 +00:00
|
|
|
nixConfig.extra-substituters = [ "https://nixos-search.cachix.org" ];
|
|
|
|
nixConfig.extra-trusted-public-keys = [ "nixos-search.cachix.org-1:1HV3YF8az4fywnH+pAd+CXFEdpTXtv9WpoivPi+H70o=" ];
|
2022-01-25 16:30:21 +00:00
|
|
|
|
2022-04-15 18:53:53 +00:00
|
|
|
inputs.nixpkgs.url = "nixpkgs/nixos-unstable";
|
2022-04-07 21:36:07 +00:00
|
|
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
2022-04-24 21:48:01 +00:00
|
|
|
inputs.nixos-org-configurations.url = "github:NixOS/nixos-org-configurations";
|
|
|
|
inputs.nixos-org-configurations.flake = false;
|
2020-06-18 22:41:01 +00:00
|
|
|
|
2022-03-17 22:00:10 +00:00
|
|
|
outputs = { self
|
|
|
|
, nixpkgs
|
|
|
|
, flake-utils
|
2022-04-24 21:48:01 +00:00
|
|
|
, nixos-org-configurations
|
2022-03-17 22:00:10 +00:00
|
|
|
}:
|
2022-04-24 21:48:01 +00:00
|
|
|
flake-utils.lib.eachDefaultSystem
|
2022-03-17 22:00:10 +00:00
|
|
|
(system:
|
2020-06-18 22:41:01 +00:00
|
|
|
let
|
2022-03-17 22:00:10 +00:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2022-04-24 21:48:01 +00:00
|
|
|
lib = nixpkgs.lib;
|
|
|
|
warnToUpgradeNix = lib.warn "Please upgrade Nix to 2.7 or later.";
|
|
|
|
version = lib.fileContents ./VERSION;
|
|
|
|
nixosChannels =
|
|
|
|
let
|
|
|
|
allChannels = (import "${nixos-org-configurations}/channels.nix").channels;
|
|
|
|
filteredChannels =
|
|
|
|
lib.filterAttrs
|
|
|
|
(n: v:
|
|
|
|
builtins.elem v.status ["beta" "stable" "rolling"] &&
|
|
|
|
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;
|
|
|
|
};
|
2022-03-17 22:00:10 +00:00
|
|
|
in rec {
|
|
|
|
|
|
|
|
packages.default = packages.flake-info;
|
2022-04-24 21:48:01 +00:00
|
|
|
packages.flake-info = import ./flake-info { inherit pkgs nixosChannels; };
|
|
|
|
packages.frontend = import ./frontend { inherit pkgs nixosChannels version; };
|
|
|
|
packages.nixosChannels = nixosChannelsFile;
|
|
|
|
|
|
|
|
devShells.default = mkDevShell {
|
|
|
|
inputsFrom = [
|
|
|
|
packages.flake-info
|
|
|
|
packages.frontend
|
|
|
|
];
|
|
|
|
extraPackages = [pkgs.rustfmt];
|
|
|
|
extraShellHook = ''
|
|
|
|
export RUST_SRC_PATH="${pkgs.rustPlatform.rustLibSrc}";
|
|
|
|
export NIXPKGS_PANDOC_FILTERS_PATH="${packages.flake-info.NIXPKGS_PANDOC_FILTERS_PATH}";
|
|
|
|
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 "========================================================"
|
|
|
|
'';
|
|
|
|
};
|
2022-03-17 22:00:10 +00:00
|
|
|
|
2022-04-24 21:48:01 +00:00
|
|
|
devShells.flake-info = mkDevShell {
|
|
|
|
inputsFrom = [packages.flake-info];
|
|
|
|
extraPackages = [pkgs.rustfmt];
|
|
|
|
extraShellHook = ''
|
2022-03-17 22:00:10 +00:00
|
|
|
export RUST_SRC_PATH="${pkgs.rustPlatform.rustLibSrc}";
|
|
|
|
export NIXPKGS_PANDOC_FILTERS_PATH="${packages.flake-info.NIXPKGS_PANDOC_FILTERS_PATH}";
|
|
|
|
'';
|
2020-06-18 22:41:01 +00:00
|
|
|
};
|
2021-08-17 08:55:08 +00:00
|
|
|
|
2022-04-24 21:48:01 +00:00
|
|
|
devShells.frontend = mkDevShell {
|
|
|
|
inputsFrom = [packages.frontend] ;
|
|
|
|
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 "========================================================"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-03-17 22:00:10 +00:00
|
|
|
# XXX: for backwards compatibility
|
|
|
|
devShell = warnToUpgradeNix devShells.default;
|
|
|
|
defaultPackage = warnToUpgradeNix packages.default;
|
|
|
|
}
|
|
|
|
);
|
2020-06-18 22:41:01 +00:00
|
|
|
}
|