packaging: Backport bower support utilities
To support nixos-16.03 the utilities to build bower components are backported inside of this PR. Once we switch to the new stable branch, we should be able to drop these pieces again.
This commit is contained in:
parent
4a9375c078
commit
22a7abe8cc
3 changed files with 91 additions and 1 deletions
|
|
@ -30,6 +30,10 @@ let
|
|||
then pythonPackages
|
||||
else getAttr pythonPackages pkgs;
|
||||
|
||||
buildBowerComponents =
|
||||
pkgs.buildBowerComponents or
|
||||
(import ./pkgs/backport-16.03-build-bower-components.nix { inherit pkgs; });
|
||||
|
||||
elem = builtins.elem;
|
||||
basename = path: with pkgs.lib; last (splitString "/" path);
|
||||
startsWith = prefix: full: let
|
||||
|
|
@ -58,7 +62,7 @@ let
|
|||
};
|
||||
nodeDependencies = nodeEnv.shell.nodeDependencies;
|
||||
|
||||
bowerComponents = pkgs.buildBowerComponents {
|
||||
bowerComponents = buildBowerComponents {
|
||||
name = "enterprise-ce-${version}";
|
||||
generated = ./pkgs/bower-packages.nix;
|
||||
src = rhodecode-enterprise-ce-src;
|
||||
|
|
|
|||
60
pkgs/backport-16.03-build-bower-components.nix
Normal file
60
pkgs/backport-16.03-build-bower-components.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# Backported buildBowerComponents so that we can also use it with the version
|
||||
# 16.03 which is the current stable at the time of this writing.
|
||||
#
|
||||
# This file can be removed once building with 16.03 is not needed anymore.
|
||||
|
||||
{ pkgs }:
|
||||
|
||||
{ buildInputs ? [], generated, ... } @ attrs:
|
||||
|
||||
let
|
||||
fetchbower = import ./backport-16.03-fetchbower.nix {
|
||||
inherit (pkgs) stdenv lib;
|
||||
inherit (pkgs.nodePackages) bower2nix;
|
||||
};
|
||||
|
||||
# Fetches the bower packages. `generated` should be the result of a
|
||||
# `bower2nix` command.
|
||||
bowerPackages = import generated {
|
||||
inherit (pkgs) buildEnv;
|
||||
inherit fetchbower;
|
||||
};
|
||||
|
||||
in pkgs.stdenv.mkDerivation (
|
||||
attrs
|
||||
//
|
||||
{
|
||||
name = "bower_components-" + attrs.name;
|
||||
|
||||
inherit bowerPackages;
|
||||
|
||||
builder = builtins.toFile "builder.sh" ''
|
||||
source $stdenv/setup
|
||||
|
||||
# The project's bower.json is required
|
||||
cp $src/bower.json .
|
||||
|
||||
# Dereference symlinks -- bower doesn't like them
|
||||
cp --recursive --reflink=auto \
|
||||
--dereference --no-preserve=mode \
|
||||
$bowerPackages bc
|
||||
|
||||
# Bower install in offline mode -- links together the fetched
|
||||
# bower packages.
|
||||
HOME=$PWD bower \
|
||||
--config.storage.packages=bc/packages \
|
||||
--config.storage.registry=bc/registry \
|
||||
--offline install
|
||||
|
||||
# Sets up a single bower_components directory within
|
||||
# the output derivation.
|
||||
mkdir -p $out
|
||||
mv bower_components $out
|
||||
'';
|
||||
|
||||
buildInputs = buildInputs ++ [
|
||||
pkgs.git
|
||||
pkgs.nodePackages.bower
|
||||
];
|
||||
}
|
||||
)
|
||||
26
pkgs/backport-16.03-fetchbower.nix
Normal file
26
pkgs/backport-16.03-fetchbower.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{ stdenv, lib, bower2nix }:
|
||||
let
|
||||
bowerVersion = version:
|
||||
let
|
||||
components = lib.splitString "#" version;
|
||||
hash = lib.last components;
|
||||
ver = if builtins.length components == 1 then version else hash;
|
||||
in ver;
|
||||
|
||||
fetchbower = name: version: target: outputHash: stdenv.mkDerivation {
|
||||
name = "${name}-${bowerVersion version}";
|
||||
buildCommand = ''
|
||||
fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
|
||||
# In some cases, the result of fetchBower is different depending
|
||||
# on the output directory (e.g. if the bower package contains
|
||||
# symlinks). So use a local output directory before copying to
|
||||
# $out.
|
||||
cp -R out $out
|
||||
'';
|
||||
outputHashMode = "recursive";
|
||||
outputHashAlgo = "sha256";
|
||||
inherit outputHash;
|
||||
buildInputs = [ bower2nix ];
|
||||
};
|
||||
|
||||
in fetchbower
|
||||
Loading…
Add table
Add a link
Reference in a new issue