-147
doc/languages-frameworks/bower.section.md
-147
doc/languages-frameworks/bower.section.md
···
1
-
# Bower {#sec-bower}
2
-
3
-
[Bower](https://bower.io) is a package manager for web site front-end components. Bower packages (comprising of build artifacts and sometimes sources) are stored in `git` repositories, typically on Github. The package registry is run by the Bower team with package metadata coming from the `bower.json` file within each package.
4
-
5
-
The end result of running Bower is a `bower_components` directory which can be included in the web app's build process.
6
-
7
-
Bower can be run interactively, by installing `nodePackages.bower`. More interestingly, the Bower components can be declared in a Nix derivation, with the help of `bower2nix`.
8
-
9
-
## bower2nix usage {#ssec-bower2nix-usage}
10
-
11
-
Suppose you have a `bower.json` with the following contents:
12
-
13
-
### Example bower.json {#ex-bowerJson}
14
-
15
-
```json
16
-
"name": "my-web-app",
17
-
"dependencies": {
18
-
"angular": "~1.5.0",
19
-
"bootstrap": "~3.3.6"
20
-
}
21
-
```
22
-
23
-
Running `bower2nix` will produce something like the following output:
24
-
25
-
```nix
26
-
{ fetchbower, buildEnv }:
27
-
buildEnv {
28
-
name = "bower-env";
29
-
ignoreCollisions = true;
30
-
paths = [
31
-
(fetchbower "angular" "1.5.3" "~1.5.0" "1749xb0firxdra4rzadm4q9x90v6pzkbd7xmcyjk6qfza09ykk9y")
32
-
(fetchbower "bootstrap" "3.3.6" "~3.3.6" "1vvqlpbfcy0k5pncfjaiskj3y6scwifxygfqnw393sjfxiviwmbv")
33
-
(fetchbower "jquery" "2.2.2" "1.9.1 - 2" "10sp5h98sqwk90y4k6hbdviwqzvzwqf47r3r51pakch5ii2y7js1")
34
-
];
35
-
}
36
-
```
37
-
38
-
Using the `bower2nix` command line arguments, the output can be redirected to a file. A name like `bower-packages.nix` would be fine.
39
-
40
-
The resulting derivation is a union of all the downloaded Bower packages (and their dependencies). To use it, they still need to be linked together by Bower, which is where `buildBowerComponents` is useful.
41
-
42
-
## buildBowerComponents function {#ssec-build-bower-components}
43
-
44
-
The function is implemented in [pkgs/development/bower-modules/generic/default.nix](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/bower-modules/generic/default.nix).
45
-
46
-
### Example buildBowerComponents {#ex-buildBowerComponents}
47
-
48
-
```nix
49
-
{
50
-
bowerComponents = buildBowerComponents {
51
-
name = "my-web-app";
52
-
generated = ./bower-packages.nix; # note 1
53
-
src = myWebApp; # note 2
54
-
};
55
-
}
56
-
```
57
-
58
-
In ["buildBowerComponents" example](#ex-buildBowerComponents) the following arguments are of special significance to the function:
59
-
60
-
1. `generated` specifies the file which was created by {command}`bower2nix`.
61
-
2. `src` is your project's sources. It needs to contain a {file}`bower.json` file.
62
-
63
-
`buildBowerComponents` will run Bower to link together the output of `bower2nix`, resulting in a `bower_components` directory which can be used.
64
-
65
-
Here is an example of a web frontend build process using `gulp`. You might use `grunt`, or anything else.
66
-
67
-
### Example build script (gulpfile.js) {#ex-bowerGulpFile}
68
-
69
-
```javascript
70
-
var gulp = require('gulp');
71
-
72
-
gulp.task('default', [], function () {
73
-
gulp.start('build');
74
-
});
75
-
76
-
gulp.task('build', [], function () {
77
-
console.log("Just a dummy gulp build");
78
-
gulp
79
-
.src(["./bower_components/**/*"])
80
-
.pipe(gulp.dest("./gulpdist/"));
81
-
});
82
-
```
83
-
84
-
### Example Full example — default.nix {#ex-buildBowerComponentsDefaultNix}
85
-
86
-
```nix
87
-
{
88
-
myWebApp ? {
89
-
outPath = ./.;
90
-
name = "myWebApp";
91
-
},
92
-
pkgs ? import <nixpkgs> { },
93
-
}:
94
-
95
-
pkgs.stdenv.mkDerivation {
96
-
name = "my-web-app-frontend";
97
-
src = myWebApp;
98
-
99
-
buildInputs = [ pkgs.nodePackages.gulp ];
100
-
101
-
bowerComponents = pkgs.buildBowerComponents {
102
-
# note 1
103
-
name = "my-web-app";
104
-
generated = ./bower-packages.nix;
105
-
src = myWebApp;
106
-
};
107
-
108
-
nativeBuildInputs = [
109
-
writableTmpDirAsHomeHook # note 3
110
-
];
111
-
112
-
buildPhase = ''
113
-
runHook preBuild
114
-
115
-
cp --reflink=auto --no-preserve=mode -R $bowerComponents/bower_components . # note 2
116
-
${pkgs.nodePackages.gulp}/bin/gulp build # note 4
117
-
118
-
runHook postBuild
119
-
'';
120
-
121
-
installPhase = ''
122
-
runHook preInstall
123
-
124
-
mv gulpdist $out
125
-
126
-
runHook postInstall
127
-
'';
128
-
}
129
-
```
130
-
131
-
A few notes about [Full example — `default.nix`](#ex-buildBowerComponentsDefaultNix):
132
-
133
-
1. The result of `buildBowerComponents` is an input to the frontend build.
134
-
2. Whether to symlink or copy the {file}`bower_components` directory depends on the build tool in use.
135
-
In this case, a copy is used to avoid {command}`gulp` silliness with permissions.
136
-
3. {command}`gulp` requires `HOME` to refer to a writeable directory.
137
-
4. The actual build command in this example is {command}`gulp`. Other tools could be used instead.
138
-
139
-
## Troubleshooting {#ssec-bower2nix-troubleshooting}
140
-
141
-
### ENOCACHE errors from buildBowerComponents {#enocache-errors-from-buildbowercomponents}
142
-
143
-
This means that Bower was looking for a package version which doesn't exist in the generated `bower-packages.nix`.
144
-
145
-
If `bower.json` has been updated, then run `bower2nix` again.
146
-
147
-
It could also be a bug in `bower2nix` or `fetchbower`. If possible, try reformulating the version specification in `bower.json`.
-1
doc/languages-frameworks/index.md
-1
doc/languages-frameworks/index.md
+10
-28
doc/redirects.json
+10
-28
doc/redirects.json
···
259
259
"release-notes.html#sec-nixpkgs-release-25.11-highlights"
260
260
],
261
261
"sec-nixpkgs-release-25.11-incompatibilities": [
262
-
"release-notes.html#sec-nixpkgs-release-25.11-incompatibilities"
262
+
"release-notes.html#sec-nixpkgs-release-25.11-incompatibilities",
263
+
"index.html#enocache-errors-from-buildbowercomponents",
264
+
"index.html#ex-bowerGulpFile",
265
+
"index.html#ex-bowerJson",
266
+
"index.html#ex-buildBowerComponents",
267
+
"index.html#ex-buildBowerComponentsDefaultNix",
268
+
"index.html#sec-bower",
269
+
"index.html#ssec-bower2nix-troubleshooting",
270
+
"index.html#ssec-bower2nix-usage",
271
+
"index.html#ssec-build-bower-components"
263
272
],
264
273
"sec-nixpkgs-release-25.11-lib": [
265
274
"release-notes.html#sec-nixpkgs-release-25.11-lib"
···
2800
2809
],
2801
2810
"elixir---phoenix-project": [
2802
2811
"index.html#elixir---phoenix-project"
2803
-
],
2804
-
"sec-bower": [
2805
-
"index.html#sec-bower"
2806
-
],
2807
-
"ssec-bower2nix-usage": [
2808
-
"index.html#ssec-bower2nix-usage"
2809
-
],
2810
-
"ex-bowerJson": [
2811
-
"index.html#ex-bowerJson"
2812
-
],
2813
-
"ssec-build-bower-components": [
2814
-
"index.html#ssec-build-bower-components"
2815
-
],
2816
-
"ex-buildBowerComponents": [
2817
-
"index.html#ex-buildBowerComponents"
2818
-
],
2819
-
"ex-bowerGulpFile": [
2820
-
"index.html#ex-bowerGulpFile"
2821
-
],
2822
-
"ex-buildBowerComponentsDefaultNix": [
2823
-
"index.html#ex-buildBowerComponentsDefaultNix"
2824
-
],
2825
-
"ssec-bower2nix-troubleshooting": [
2826
-
"index.html#ssec-bower2nix-troubleshooting"
2827
-
],
2828
-
"enocache-errors-from-buildbowercomponents": [
2829
-
"index.html#enocache-errors-from-buildbowercomponents"
2830
2812
],
2831
2813
"sec-chicken": [
2832
2814
"index.html#sec-chicken"
+2
doc/release-notes/rl-2511.section.md
+2
doc/release-notes/rl-2511.section.md
···
21
21
22
22
- `mono4` and `mono5` have been removed. Use `mono6` or `mono` instead.
23
23
24
+
- Everything related to `bower` was removed, as it is deprecated and not used by anything in nixpkgs.
25
+
24
26
- The `offrss` package was removed due to lack of upstream maintenance since 2012. It's recommended for users to migrate to another RSS reader
25
27
26
28
- `installShellFiles`: Allow installManPage to take a piped input, add the `--name` flag for renaming the file when installed. Can also append `--` to opt-out of all subsequent parsing.
-41
pkgs/build-support/fetchbower/default.nix
-41
pkgs/build-support/fetchbower/default.nix
···
1
-
{
2
-
stdenvNoCC,
3
-
lib,
4
-
bower2nix,
5
-
cacert,
6
-
}:
7
-
let
8
-
bowerVersion =
9
-
version:
10
-
let
11
-
components = lib.splitString "#" version;
12
-
hash = lib.last components;
13
-
ver = if builtins.length components == 1 then (cleanName version) else hash;
14
-
in
15
-
ver;
16
-
17
-
cleanName = name: lib.replaceStrings [ "/" ":" ] [ "-" "-" ] name;
18
-
19
-
fetchbower =
20
-
name: version: target: outputHash:
21
-
stdenvNoCC.mkDerivation {
22
-
name = "${cleanName name}-${bowerVersion version}";
23
-
buildCommand = ''
24
-
fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
25
-
# In some cases, the result of fetchBower is different depending
26
-
# on the output directory (e.g. if the bower package contains
27
-
# symlinks). So use a local output directory before copying to
28
-
# $out.
29
-
cp -R out $out
30
-
'';
31
-
outputHashMode = "recursive";
32
-
outputHashAlgo = "sha256";
33
-
inherit outputHash;
34
-
nativeBuildInputs = [
35
-
bower2nix
36
-
cacert
37
-
];
38
-
};
39
-
40
-
in
41
-
fetchbower
-44
pkgs/by-name/bo/bower2nix/package.nix
-44
pkgs/by-name/bo/bower2nix/package.nix
···
1
-
{
2
-
buildNpmPackage,
3
-
fetchFromGitHub,
4
-
git,
5
-
lib,
6
-
nix,
7
-
unstableGitUpdater,
8
-
}:
9
-
10
-
buildNpmPackage rec {
11
-
pname = "bower2nix";
12
-
version = "3.2.0-unstable-2024-06-25";
13
-
14
-
src = fetchFromGitHub {
15
-
owner = "rvl";
16
-
repo = "bower2nix";
17
-
rev = "b5da44f055c7561ed7a46226b3be0070e07d80e6";
18
-
hash = "sha256-da+m2UWQ83tW1o0P1qvw35KpsXL/BDTeShg4KxL+7Ck=";
19
-
};
20
-
21
-
npmDepsHash = "sha256-TK1sqF2J/hQuP3bgGA4MolLA7LWWuYNnqf4gDyU154k=";
22
-
23
-
npmBuildScript = "prepare";
24
-
25
-
makeWrapperArgs = [
26
-
"--prefix PATH : ${
27
-
lib.makeBinPath [
28
-
git
29
-
nix
30
-
]
31
-
}"
32
-
];
33
-
34
-
passthru.updateScript = unstableGitUpdater { tagPrefix = "v"; };
35
-
36
-
meta = {
37
-
changelog = "https://github.com/rvl/bower2nix/releases/tag/v${version}";
38
-
description = "Generate nix expressions to fetch bower dependencies";
39
-
homepage = "https://github.com/rvl/bower2nix";
40
-
license = lib.licenses.gpl3Only;
41
-
mainProgram = "bower2nix";
42
-
maintainers = [ ];
43
-
};
44
-
}
-13
pkgs/by-name/me/mediagoblin/bower-packages.nix
-13
pkgs/by-name/me/mediagoblin/bower-packages.nix
···
1
-
{ fetchbower, buildEnv }:
2
-
buildEnv {
3
-
name = "bower-env";
4
-
ignoreCollisions = true;
5
-
paths = [
6
-
(fetchbower "jquery" "2.1.4" "~2.1.3" "1ywrpk2xsr6ghkm3j9gfnl9r3jn6xarfamp99b0bcm57kq9fm2k0")
7
-
(fetchbower "video.js" "5.20.5" "~5.20.1" "1agvvid2valba7xxypknbb3k578jz8sa4rsmq5z2yc5010k3nkqp")
8
-
(fetchbower "videojs-resolution-switcher" "0.4.2" "~0.4.2"
9
-
"1bz2q1wwdglaxbb20fin9djgs1c71jywxhlrm16hm4bzg708ycaf"
10
-
)
11
-
(fetchbower "leaflet" "0.7.7" "~0.7.3" "0jim285bljmxxngpm3yx6bnnd10n2whwkgmmhzpcd1rdksnr5nca")
12
-
];
13
-
}
+24
-7
pkgs/by-name/me/mediagoblin/package.nix
+24
-7
pkgs/by-name/me/mediagoblin/package.nix
···
1
1
{
2
2
lib,
3
-
buildBowerComponents,
3
+
buildNpmPackage,
4
4
fetchFromSourcehut,
5
+
fetchpatch,
5
6
gobject-introspection,
6
7
gst_all_1,
7
8
poppler-utils,
···
34
35
hash = "sha256-Y1VnXLHEl6TR8nt+vKSfoCwleQ+oA2WPMN9q4fW9R3s=";
35
36
};
36
37
37
-
extlib = buildBowerComponents {
38
+
patches = [
39
+
(fetchpatch {
40
+
url = "https://git.sr.ht/~mediagoblin/mediagoblin/commit/95a591bb2ffdeed059b926059155fd0802e6b1e6.patch";
41
+
excludes = [ "docs/source/siteadmin/relnotes.rst" ];
42
+
hash = "sha256-Coff02bewl6E9bHeMy/6tA2dngKcw/c33xk9nmMl/Bk=";
43
+
})
44
+
];
45
+
46
+
extlib = buildNpmPackage {
38
47
name = "mediagoblin-extlib";
39
-
generated = ./bower-packages.nix;
40
-
inherit src;
48
+
inherit src patches;
49
+
50
+
npmDepsHash = "sha256-wtk5MgsWEpuz3V/EcozEAMOa8UeCgdjhR5wxaiaMugY=";
51
+
52
+
dontNpmBuild = true;
53
+
54
+
installPhase = ''
55
+
mkdir -p $out/node_modules/
56
+
cp -r node_modules/{jquery,video.js,videojs-resolution-switcher,leaflet} $out/node_modules/
57
+
'';
41
58
};
42
59
in
43
60
python.pkgs.buildPythonApplication rec {
44
61
format = "setuptools";
45
62
pname = "mediagoblin";
46
-
inherit version src;
63
+
inherit version src patches;
47
64
48
65
postPatch = ''
49
66
# https://git.sr.ht/~mediagoblin/mediagoblin/tree/bf61d38df21748aadb480c53fdd928647285e35f/item/.guix/modules/mediagoblin-package.scm#L60-62
···
128
145
'';
129
146
130
147
postInstall = ''
131
-
lndir -silent ${extlib}/bower_components/ $out/${python.sitePackages}/mediagoblin/static/extlib/
148
+
lndir -silent ${extlib}/node_modules $out/${python.sitePackages}/mediagoblin/static/extlib/
132
149
133
150
ln -rs $out/${python.sitePackages}/mediagoblin/static/extlib/jquery/dist/jquery.js $out/${python.sitePackages}/mediagoblin/static/js/extlib/jquery.js
134
151
ln -rs $out/${python.sitePackages}/mediagoblin/static/extlib/leaflet/dist/leaflet.css $out/${python.sitePackages}/mediagoblin/static/extlib/leaflet/leaflet.css
···
151
168
pythonImportsCheck = [ "mediagoblin" ];
152
169
153
170
passthru = {
154
-
inherit python;
171
+
inherit extlib python;
155
172
};
156
173
157
174
meta = {
-51
pkgs/development/bower-modules/generic/default.nix
-51
pkgs/development/bower-modules/generic/default.nix
···
1
-
{ pkgs }:
2
-
3
-
{
4
-
buildInputs ? [ ],
5
-
generated,
6
-
...
7
-
}@attrs:
8
-
9
-
let
10
-
# Fetches the bower packages. `generated` should be the result of a
11
-
# `bower2nix` command.
12
-
bowerPackages = import generated {
13
-
inherit (pkgs) buildEnv fetchbower;
14
-
};
15
-
16
-
in
17
-
pkgs.stdenv.mkDerivation (
18
-
attrs
19
-
// {
20
-
name = "bower_components-" + attrs.name;
21
-
22
-
inherit bowerPackages;
23
-
24
-
builder = builtins.toFile "builder.sh" ''
25
-
# The project's bower.json is required
26
-
cp $src/bower.json .
27
-
28
-
# Dereference symlinks -- bower doesn't like them
29
-
cp --recursive --reflink=auto \
30
-
--dereference --no-preserve=mode \
31
-
$bowerPackages bc
32
-
33
-
# Bower install in offline mode -- links together the fetched
34
-
# bower packages.
35
-
HOME=$PWD bower \
36
-
--config.storage.packages=bc/packages \
37
-
--config.storage.registry=bc/registry \
38
-
--offline install
39
-
40
-
# Sets up a single bower_components directory within
41
-
# the output derivation.
42
-
mkdir -p $out
43
-
mv bower_components $out
44
-
'';
45
-
46
-
buildInputs = buildInputs ++ [
47
-
pkgs.git
48
-
pkgs.nodePackages.bower
49
-
];
50
-
}
51
-
)
+1
pkgs/development/node-packages/aliases.nix
+1
pkgs/development/node-packages/aliases.nix
···
63
63
inherit (pkgs) bash-language-server; # added 2024-06-07
64
64
bibtex-tidy = pkgs.bibtex-tidy; # added 2023-07-30
65
65
bitwarden-cli = pkgs.bitwarden-cli; # added 2023-07-25
66
+
bower = throw "bower was removed because it was deprecated"; # added 2025-09-17
66
67
inherit (pkgs) bower2nix; # added 2024-08-23
67
68
inherit (pkgs) btc-rpc-explorer; # added 2023-08-17
68
69
inherit (pkgs) carbon-now-cli; # added 2023-08-17
-1
pkgs/development/node-packages/node-packages.json
-1
pkgs/development/node-packages/node-packages.json
-18
pkgs/development/node-packages/node-packages.nix
-18
pkgs/development/node-packages/node-packages.nix
···
46557
46557
bypassCache = true;
46558
46558
reconstructLock = true;
46559
46559
};
46560
-
bower = nodeEnv.buildNodePackage {
46561
-
name = "bower";
46562
-
packageName = "bower";
46563
-
version = "1.8.14";
46564
-
src = fetchurl {
46565
-
url = "https://registry.npmjs.org/bower/-/bower-1.8.14.tgz";
46566
-
sha512 = "8Rq058FD91q9Nwthyhw0la9fzpBz0iwZTrt51LWl+w+PnJgZk9J+5wp3nibsJcIUPglMYXr4NRBaR+TUj0OkBQ==";
46567
-
};
46568
-
buildInputs = globalBuildInputs;
46569
-
meta = {
46570
-
description = "The browser package manager";
46571
-
homepage = "http://bower.io";
46572
-
license = "MIT";
46573
-
};
46574
-
production = true;
46575
-
bypassCache = true;
46576
-
reconstructLock = true;
46577
-
};
46578
46560
browserify = nodeEnv.buildNodePackage {
46579
46561
name = "browserify";
46580
46562
packageName = "browserify";
+3
pkgs/top-level/aliases.nix
+3
pkgs/top-level/aliases.nix
···
540
540
boost184 = throw "Boost 1.84 has been removed as it is obsolete and no longer used by anything in Nixpkgs"; # Added 2024-11-24
541
541
boost185 = throw "Boost 1.85 has been removed as it is obsolete and no longer used by anything in Nixpkgs"; # Added 2024-11-24
542
542
boost_process = throw "boost_process has been removed as it is included in regular boost"; # Added 2024-05-01
543
+
bower2nix = throw "bower2nix has been removed as bower was removed. It is recommended to migrate to yarn."; # Added 2025-09-17
543
544
bpb = throw "bpb has been removed as it is unmaintained and not compatible with recent Rust versions"; # Added 2024-04-30
544
545
bpftool = throw "'bpftool' has been renamed to/replaced by 'bpftools'"; # Converted to throw 2024-10-17
545
546
brasero-original = lib.warnOnInstantiate "Use 'brasero-unwrapped' instead of 'brasero-original'" brasero-unwrapped; # Added 2024-09-29
···
551
552
budgie = throw "The `budgie` scope has been removed and all packages moved to the top-level"; # Added 2024-07-14
552
553
budgiePlugins = throw "The `budgiePlugins` scope has been removed and all packages moved to the top-level"; # Added 2024-07-14
553
554
buildBarebox = throw "buildBarebox has been removed due to lack of interest in maintaining it in nixpkgs"; # Added 2025-04-19
555
+
buildBowerComponents = throw "buildBowerComponents has been removed as bower was removed. It is recommended to migrate to yarn."; # Added 2025-09-17
554
556
buildGo122Module = throw "Go 1.22 is end-of-life, and 'buildGo122Module' has been removed. Please use a newer builder version."; # Added 2025-03-28
555
557
buildGo123Module = throw "Go 1.23 is end-of-life, and 'buildGo123Module' has been removed. Please use a newer builder version."; # Added 2025-08-13
556
558
buildGoPackage = throw "`buildGoPackage` has been deprecated and removed, see the Go section in the nixpkgs manual for details"; # Added 2024-11-18
···
877
879
fdr = throw "fdr has been removed, as it cannot be built from source and depends on Python 2.x"; # Added 2025-03-19
878
880
inherit (luaPackages) fennel; # Added 2022-09-24
879
881
ferdi = throw "'ferdi' has been removed, upstream does not exist anymore and the package is insecure"; # Added 2024-08-22
882
+
fetchbower = throw "fetchbower has been removed as bower was removed. It is recommended to migrate to yarn."; # Added 2025-09-17
880
883
fetchFromGithub = throw "You meant fetchFromGitHub, with a capital H"; # preserve, reason: common typo
881
884
ffmpeg_5 = throw "ffmpeg_5 has been removed, please use another version"; # Added 2024-07-12
882
885
ffmpeg_5-headless = throw "ffmpeg_5-headless has been removed, please use another version"; # Added 2024-07-12
-8
pkgs/top-level/all-packages.nix
-8
pkgs/top-level/all-packages.nix
···
466
466
python3Packages = python311Packages;
467
467
};
468
468
469
-
fetchbower = callPackage ../build-support/fetchbower { };
470
-
471
469
fetchbzr = callPackage ../build-support/fetchbzr { };
472
470
473
471
fetchcvs =
···
9107
9105
saxon_11-he
9108
9106
saxon_12-he
9109
9107
;
9110
-
9111
-
### DEVELOPMENT / LIBRARIES / JAVASCRIPT
9112
-
9113
-
### DEVELOPMENT / BOWER MODULES (JAVASCRIPT)
9114
-
9115
-
buildBowerComponents = callPackage ../development/bower-modules/generic { };
9116
9108
9117
9109
### DEVELOPMENT / GO
9118
9110