Skip to content

Commit

Permalink
flakify
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Jun 18, 2020
1 parent c420d05 commit 1ba9ece
Show file tree
Hide file tree
Showing 12 changed files with 1,083 additions and 145 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/cron.yml
Expand Up @@ -17,10 +17,23 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Installing Nix
uses: cachix/install-nix-action@v8

- name: Installing NixFlakes
run: |
nix-env -iA nixpkgs.nixFlakes
echo "::add-path::$HOME/.nix-profile/bin"
echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf
nix --version
cat /etc/nix/nix.conf
- name: Building import-scripts
run: |
nix build ./#packages.x86_64-linux.import-scripts
- name: Import ${{ matrix.channel }} channel
run: |
cd scripts/
./import-channel --es-url ${{ secrets.ELASTICSEARCH_URL }} --channel ${{ matrix.channel }} -vvv
./result/bin/import-channel --es-url ${{ secrets.ELASTICSEARCH_URL }} --channel ${{ matrix.channel }} -vvv
if: github.repository == 'NixOS/nixos-search'
19 changes: 17 additions & 2 deletions .github/workflows/main.yml
Expand Up @@ -12,13 +12,28 @@ jobs:
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Installing Nix
uses: cachix/install-nix-action@v8
uses: cachix/install-nix-action@v9

- name: Installing NixFlakes
run: |
nix-env -iA nixpkgs.nixFlakes
echo "::add-path::$HOME/.nix-profile/bin"
echo 'experimental-features = nix-command flakes' | sudo tee -a /etc/nix/nix.conf
nix --version
cat /etc/nix/nix.conf
- name: Building import-scripts
run: |
nix build ./#packages.x86_64-linux.import-scripts
- name: Building search.nixos.org
run: |
nix-build
nix build ./#packages.x86_64-linux.frontend
mkdir ./dist
cp -RL ./result/* ./dist/
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v1.0.5
env:
Expand Down
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
7
23 changes: 10 additions & 13 deletions default.nix
@@ -1,15 +1,9 @@
{ pkgs ? import <nixpkgs> {}
{ pkgs ? import <nixpkgs> { }
, version ? "0"
}:

let
package = builtins.fromJSON (builtins.readFile ./package.json);
yarn2nix = import (pkgs.fetchFromGitHub {
owner = "moretea";
repo = "yarn2nix";
rev = "9e7279edde2a4e0f5ec04c53f5cd64440a27a1ae";
sha256 = "sha256-x77mYSvwA4bd/uCwL0rRw+8mwH+dR/UfWnn4YXmm4n8=";
}) { inherit pkgs; };
yarnPkg = yarn2nix.mkYarnPackage rec {
yarnPkg = pkgs.yarn2nix-moretea.mkYarnPackage rec {
name = "${package.name}-yarn-${package.version}";
src = null;
dontUnpack = true;
Expand All @@ -28,24 +22,27 @@ let
'';
pkgConfig = {
node-sass = {
buildInputs = [ pkgs.python pkgs.libsass pkgs.pkgconfig];
buildInputs = [ pkgs.python pkgs.libsass pkgs.pkgconfig ];
postInstall = ''
LIBSASS_EXT=auto yarn --offline run build
rm build/config.gypi
'';
};
};
publishBinsFor =
[ "webpack"
[
"webpack"
"webpack-dev-server"
];
};
in pkgs.stdenv.mkDerivation {
in
pkgs.stdenv.mkDerivation {
name = "${package.name}-${package.version}";
src = pkgs.lib.cleanSource ./.;

buildInputs =
[ yarnPkg
[
yarnPkg
] ++
(with pkgs; [
nodejs
Expand Down
65 changes: 65 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions flake.nix
@@ -0,0 +1,35 @@
{
description = "Code behind search.nixos.org";

inputs = {
nixpkgs = { url = "nixpkgs/nixos-unstable"; };
poetry2nix = { url = "github:nix-community/poetry2nix"; };
};

outputs = { self, nixpkgs, poetry2nix }:
let
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
allPackages = system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
poetry2nix.overlay
];
};
version = pkgs.lib.removeSuffix "\n" (builtins.readFile "${self}/VERSION");
in
{
import_scripts = import ./import-scripts {
inherit pkgs version;
};
frontend = import ./. {
inherit pkgs version;
};
};
in
{
packages = forAllSystems allPackages;
};
}
23 changes: 23 additions & 0 deletions import-scripts/default.nix
@@ -0,0 +1,23 @@
{ pkgs ? import <nixpkgs> { }
, version ? "0"
}:
let
inherit (pkgs.poetry2nix) mkPoetryApplication overrides;
in
mkPoetryApplication {
projectDir = ./.;
overrides = overrides.withDefaults (self: super: {
pypandoc = super.pypandoc.overridePythonAttrs (old: {
postPatch = ''
sed -i '/^__pandoc_path = None$/c__pandoc_path = "${pkgs.pandoc}/bin/pandoc"' pypandoc/__init__.py
'';
});
});
checkPhase = ''
black --diff --check ./import_scripts
flake8 --ignore W503,E501,E265,E203 ./import_scripts
'';
postInstall = ''
wrapProgram $out/bin/import-channel --set INDEX_SCHEMA_VERSION "${version}"
'';
}
Empty file.

0 comments on commit 1ba9ece

Please sign in to comment.