treewide: remove bower (#443594)

This commit is contained in:
Sandro
2025-09-28 13:15:39 +00:00
committed by GitHub
14 changed files with 40 additions and 359 deletions

View File

@@ -1,147 +0,0 @@
# Bower {#sec-bower}
[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.
The end result of running Bower is a `bower_components` directory which can be included in the web app's build process.
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`.
## bower2nix usage {#ssec-bower2nix-usage}
Suppose you have a `bower.json` with the following contents:
### Example bower.json {#ex-bowerJson}
```json
"name": "my-web-app",
"dependencies": {
"angular": "~1.5.0",
"bootstrap": "~3.3.6"
}
```
Running `bower2nix` will produce something like the following output:
```nix
{ fetchbower, buildEnv }:
buildEnv {
name = "bower-env";
ignoreCollisions = true;
paths = [
(fetchbower "angular" "1.5.3" "~1.5.0" "1749xb0firxdra4rzadm4q9x90v6pzkbd7xmcyjk6qfza09ykk9y")
(fetchbower "bootstrap" "3.3.6" "~3.3.6" "1vvqlpbfcy0k5pncfjaiskj3y6scwifxygfqnw393sjfxiviwmbv")
(fetchbower "jquery" "2.2.2" "1.9.1 - 2" "10sp5h98sqwk90y4k6hbdviwqzvzwqf47r3r51pakch5ii2y7js1")
];
}
```
Using the `bower2nix` command line arguments, the output can be redirected to a file. A name like `bower-packages.nix` would be fine.
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.
## buildBowerComponents function {#ssec-build-bower-components}
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).
### Example buildBowerComponents {#ex-buildBowerComponents}
```nix
{
bowerComponents = buildBowerComponents {
name = "my-web-app";
generated = ./bower-packages.nix; # note 1
src = myWebApp; # note 2
};
}
```
In ["buildBowerComponents" example](#ex-buildBowerComponents) the following arguments are of special significance to the function:
1. `generated` specifies the file which was created by {command}`bower2nix`.
2. `src` is your project's sources. It needs to contain a {file}`bower.json` file.
`buildBowerComponents` will run Bower to link together the output of `bower2nix`, resulting in a `bower_components` directory which can be used.
Here is an example of a web frontend build process using `gulp`. You might use `grunt`, or anything else.
### Example build script (gulpfile.js) {#ex-bowerGulpFile}
```javascript
var gulp = require('gulp');
gulp.task('default', [], function () {
gulp.start('build');
});
gulp.task('build', [], function () {
console.log("Just a dummy gulp build");
gulp
.src(["./bower_components/**/*"])
.pipe(gulp.dest("./gulpdist/"));
});
```
### Example Full example — default.nix {#ex-buildBowerComponentsDefaultNix}
```nix
{
myWebApp ? {
outPath = ./.;
name = "myWebApp";
},
pkgs ? import <nixpkgs> { },
}:
pkgs.stdenv.mkDerivation {
name = "my-web-app-frontend";
src = myWebApp;
buildInputs = [ pkgs.nodePackages.gulp ];
bowerComponents = pkgs.buildBowerComponents {
# note 1
name = "my-web-app";
generated = ./bower-packages.nix;
src = myWebApp;
};
nativeBuildInputs = [
writableTmpDirAsHomeHook # note 3
];
buildPhase = ''
runHook preBuild
cp --reflink=auto --no-preserve=mode -R $bowerComponents/bower_components . # note 2
${pkgs.nodePackages.gulp}/bin/gulp build # note 4
runHook postBuild
'';
installPhase = ''
runHook preInstall
mv gulpdist $out
runHook postInstall
'';
}
```
A few notes about [Full example — `default.nix`](#ex-buildBowerComponentsDefaultNix):
1. The result of `buildBowerComponents` is an input to the frontend build.
2. Whether to symlink or copy the {file}`bower_components` directory depends on the build tool in use.
In this case, a copy is used to avoid {command}`gulp` silliness with permissions.
3. {command}`gulp` requires `HOME` to refer to a writeable directory.
4. The actual build command in this example is {command}`gulp`. Other tools could be used instead.
## Troubleshooting {#ssec-bower2nix-troubleshooting}
### ENOCACHE errors from buildBowerComponents {#enocache-errors-from-buildbowercomponents}
This means that Bower was looking for a package version which doesn't exist in the generated `bower-packages.nix`.
If `bower.json` has been updated, then run `bower2nix` again.
It could also be a bug in `bower2nix` or `fetchbower`. If possible, try reformulating the version specification in `bower.json`.

View File

@@ -55,7 +55,6 @@ agda.section.md
android.section.md android.section.md
astal.section.md astal.section.md
beam.section.md beam.section.md
bower.section.md
chicken.section.md chicken.section.md
coq.section.md coq.section.md
cosmic.section.md cosmic.section.md

View File

@@ -259,7 +259,16 @@
"release-notes.html#sec-nixpkgs-release-25.11-highlights" "release-notes.html#sec-nixpkgs-release-25.11-highlights"
], ],
"sec-nixpkgs-release-25.11-incompatibilities": [ "sec-nixpkgs-release-25.11-incompatibilities": [
"release-notes.html#sec-nixpkgs-release-25.11-incompatibilities" "release-notes.html#sec-nixpkgs-release-25.11-incompatibilities",
"index.html#enocache-errors-from-buildbowercomponents",
"index.html#ex-bowerGulpFile",
"index.html#ex-bowerJson",
"index.html#ex-buildBowerComponents",
"index.html#ex-buildBowerComponentsDefaultNix",
"index.html#sec-bower",
"index.html#ssec-bower2nix-troubleshooting",
"index.html#ssec-bower2nix-usage",
"index.html#ssec-build-bower-components"
], ],
"sec-nixpkgs-release-25.11-lib": [ "sec-nixpkgs-release-25.11-lib": [
"release-notes.html#sec-nixpkgs-release-25.11-lib" "release-notes.html#sec-nixpkgs-release-25.11-lib"
@@ -2801,33 +2810,6 @@
"elixir---phoenix-project": [ "elixir---phoenix-project": [
"index.html#elixir---phoenix-project" "index.html#elixir---phoenix-project"
], ],
"sec-bower": [
"index.html#sec-bower"
],
"ssec-bower2nix-usage": [
"index.html#ssec-bower2nix-usage"
],
"ex-bowerJson": [
"index.html#ex-bowerJson"
],
"ssec-build-bower-components": [
"index.html#ssec-build-bower-components"
],
"ex-buildBowerComponents": [
"index.html#ex-buildBowerComponents"
],
"ex-bowerGulpFile": [
"index.html#ex-bowerGulpFile"
],
"ex-buildBowerComponentsDefaultNix": [
"index.html#ex-buildBowerComponentsDefaultNix"
],
"ssec-bower2nix-troubleshooting": [
"index.html#ssec-bower2nix-troubleshooting"
],
"enocache-errors-from-buildbowercomponents": [
"index.html#enocache-errors-from-buildbowercomponents"
],
"sec-chicken": [ "sec-chicken": [
"index.html#sec-chicken" "index.html#sec-chicken"
], ],

View File

@@ -21,6 +21,8 @@
- `mono4` and `mono5` have been removed. Use `mono6` or `mono` instead. - `mono4` and `mono5` have been removed. Use `mono6` or `mono` instead.
- Everything related to `bower` was removed, as it is deprecated and not used by anything in nixpkgs.
- The `offrss` package was removed due to lack of upstream maintenance since 2012. It's recommended for users to migrate to another RSS reader - The `offrss` package was removed due to lack of upstream maintenance since 2012. It's recommended for users to migrate to another RSS reader
- `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. - `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.

View File

@@ -1,41 +0,0 @@
{
stdenvNoCC,
lib,
bower2nix,
cacert,
}:
let
bowerVersion =
version:
let
components = lib.splitString "#" version;
hash = lib.last components;
ver = if builtins.length components == 1 then (cleanName version) else hash;
in
ver;
cleanName = name: lib.replaceStrings [ "/" ":" ] [ "-" "-" ] name;
fetchbower =
name: version: target: outputHash:
stdenvNoCC.mkDerivation {
name = "${cleanName 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;
nativeBuildInputs = [
bower2nix
cacert
];
};
in
fetchbower

View File

@@ -1,44 +0,0 @@
{
buildNpmPackage,
fetchFromGitHub,
git,
lib,
nix,
unstableGitUpdater,
}:
buildNpmPackage rec {
pname = "bower2nix";
version = "3.2.0-unstable-2024-06-25";
src = fetchFromGitHub {
owner = "rvl";
repo = "bower2nix";
rev = "b5da44f055c7561ed7a46226b3be0070e07d80e6";
hash = "sha256-da+m2UWQ83tW1o0P1qvw35KpsXL/BDTeShg4KxL+7Ck=";
};
npmDepsHash = "sha256-TK1sqF2J/hQuP3bgGA4MolLA7LWWuYNnqf4gDyU154k=";
npmBuildScript = "prepare";
makeWrapperArgs = [
"--prefix PATH : ${
lib.makeBinPath [
git
nix
]
}"
];
passthru.updateScript = unstableGitUpdater { tagPrefix = "v"; };
meta = {
changelog = "https://github.com/rvl/bower2nix/releases/tag/v${version}";
description = "Generate nix expressions to fetch bower dependencies";
homepage = "https://github.com/rvl/bower2nix";
license = lib.licenses.gpl3Only;
mainProgram = "bower2nix";
maintainers = [ ];
};
}

View File

@@ -1,13 +0,0 @@
{ fetchbower, buildEnv }:
buildEnv {
name = "bower-env";
ignoreCollisions = true;
paths = [
(fetchbower "jquery" "2.1.4" "~2.1.3" "1ywrpk2xsr6ghkm3j9gfnl9r3jn6xarfamp99b0bcm57kq9fm2k0")
(fetchbower "video.js" "5.20.5" "~5.20.1" "1agvvid2valba7xxypknbb3k578jz8sa4rsmq5z2yc5010k3nkqp")
(fetchbower "videojs-resolution-switcher" "0.4.2" "~0.4.2"
"1bz2q1wwdglaxbb20fin9djgs1c71jywxhlrm16hm4bzg708ycaf"
)
(fetchbower "leaflet" "0.7.7" "~0.7.3" "0jim285bljmxxngpm3yx6bnnd10n2whwkgmmhzpcd1rdksnr5nca")
];
}

View File

@@ -1,7 +1,8 @@
{ {
lib, lib,
buildBowerComponents, buildNpmPackage,
fetchFromSourcehut, fetchFromSourcehut,
fetchpatch,
gobject-introspection, gobject-introspection,
gst_all_1, gst_all_1,
poppler-utils, poppler-utils,
@@ -34,16 +35,32 @@ let
hash = "sha256-Y1VnXLHEl6TR8nt+vKSfoCwleQ+oA2WPMN9q4fW9R3s="; hash = "sha256-Y1VnXLHEl6TR8nt+vKSfoCwleQ+oA2WPMN9q4fW9R3s=";
}; };
extlib = buildBowerComponents { patches = [
(fetchpatch {
url = "https://git.sr.ht/~mediagoblin/mediagoblin/commit/95a591bb2ffdeed059b926059155fd0802e6b1e6.patch";
excludes = [ "docs/source/siteadmin/relnotes.rst" ];
hash = "sha256-Coff02bewl6E9bHeMy/6tA2dngKcw/c33xk9nmMl/Bk=";
})
];
extlib = buildNpmPackage {
name = "mediagoblin-extlib"; name = "mediagoblin-extlib";
generated = ./bower-packages.nix; inherit src patches;
inherit src;
npmDepsHash = "sha256-wtk5MgsWEpuz3V/EcozEAMOa8UeCgdjhR5wxaiaMugY=";
dontNpmBuild = true;
installPhase = ''
mkdir -p $out/node_modules/
cp -r node_modules/{jquery,video.js,videojs-resolution-switcher,leaflet} $out/node_modules/
'';
}; };
in in
python.pkgs.buildPythonApplication rec { python.pkgs.buildPythonApplication rec {
format = "setuptools"; format = "setuptools";
pname = "mediagoblin"; pname = "mediagoblin";
inherit version src; inherit version src patches;
postPatch = '' postPatch = ''
# https://git.sr.ht/~mediagoblin/mediagoblin/tree/bf61d38df21748aadb480c53fdd928647285e35f/item/.guix/modules/mediagoblin-package.scm#L60-62 # https://git.sr.ht/~mediagoblin/mediagoblin/tree/bf61d38df21748aadb480c53fdd928647285e35f/item/.guix/modules/mediagoblin-package.scm#L60-62
@@ -128,7 +145,7 @@ python.pkgs.buildPythonApplication rec {
''; '';
postInstall = '' postInstall = ''
lndir -silent ${extlib}/bower_components/ $out/${python.sitePackages}/mediagoblin/static/extlib/ lndir -silent ${extlib}/node_modules $out/${python.sitePackages}/mediagoblin/static/extlib/
ln -rs $out/${python.sitePackages}/mediagoblin/static/extlib/jquery/dist/jquery.js $out/${python.sitePackages}/mediagoblin/static/js/extlib/jquery.js ln -rs $out/${python.sitePackages}/mediagoblin/static/extlib/jquery/dist/jquery.js $out/${python.sitePackages}/mediagoblin/static/js/extlib/jquery.js
ln -rs $out/${python.sitePackages}/mediagoblin/static/extlib/leaflet/dist/leaflet.css $out/${python.sitePackages}/mediagoblin/static/extlib/leaflet/leaflet.css ln -rs $out/${python.sitePackages}/mediagoblin/static/extlib/leaflet/dist/leaflet.css $out/${python.sitePackages}/mediagoblin/static/extlib/leaflet/leaflet.css
@@ -151,7 +168,7 @@ python.pkgs.buildPythonApplication rec {
pythonImportsCheck = [ "mediagoblin" ]; pythonImportsCheck = [ "mediagoblin" ];
passthru = { passthru = {
inherit python; inherit extlib python;
}; };
meta = { meta = {

View File

@@ -1,51 +0,0 @@
{ pkgs }:
{
buildInputs ? [ ],
generated,
...
}@attrs:
let
# Fetches the bower packages. `generated` should be the result of a
# `bower2nix` command.
bowerPackages = import generated {
inherit (pkgs) buildEnv fetchbower;
};
in
pkgs.stdenv.mkDerivation (
attrs
// {
name = "bower_components-" + attrs.name;
inherit bowerPackages;
builder = builtins.toFile "builder.sh" ''
# 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
];
}
)

View File

@@ -63,6 +63,7 @@ mapAliases {
inherit (pkgs) bash-language-server; # added 2024-06-07 inherit (pkgs) bash-language-server; # added 2024-06-07
bibtex-tidy = pkgs.bibtex-tidy; # added 2023-07-30 bibtex-tidy = pkgs.bibtex-tidy; # added 2023-07-30
bitwarden-cli = pkgs.bitwarden-cli; # added 2023-07-25 bitwarden-cli = pkgs.bitwarden-cli; # added 2023-07-25
bower = throw "bower was removed because it was deprecated"; # added 2025-09-17
inherit (pkgs) bower2nix; # added 2024-08-23 inherit (pkgs) bower2nix; # added 2024-08-23
inherit (pkgs) btc-rpc-explorer; # added 2023-08-17 inherit (pkgs) btc-rpc-explorer; # added 2023-08-17
inherit (pkgs) carbon-now-cli; # added 2023-08-17 inherit (pkgs) carbon-now-cli; # added 2023-08-17

View File

@@ -18,7 +18,6 @@
, "audiosprite" , "audiosprite"
, "aws-cdk" , "aws-cdk"
, "awesome-lint" , "awesome-lint"
, "bower"
, "browserify" , "browserify"
, "browser-sync" , "browser-sync"
, "cdk8s-cli" , "cdk8s-cli"

View File

@@ -46557,24 +46557,6 @@ in
bypassCache = true; bypassCache = true;
reconstructLock = true; reconstructLock = true;
}; };
bower = nodeEnv.buildNodePackage {
name = "bower";
packageName = "bower";
version = "1.8.14";
src = fetchurl {
url = "https://registry.npmjs.org/bower/-/bower-1.8.14.tgz";
sha512 = "8Rq058FD91q9Nwthyhw0la9fzpBz0iwZTrt51LWl+w+PnJgZk9J+5wp3nibsJcIUPglMYXr4NRBaR+TUj0OkBQ==";
};
buildInputs = globalBuildInputs;
meta = {
description = "The browser package manager";
homepage = "http://bower.io";
license = "MIT";
};
production = true;
bypassCache = true;
reconstructLock = true;
};
browserify = nodeEnv.buildNodePackage { browserify = nodeEnv.buildNodePackage {
name = "browserify"; name = "browserify";
packageName = "browserify"; packageName = "browserify";

View File

@@ -540,6 +540,7 @@ mapAliases {
boost184 = throw "Boost 1.84 has been removed as it is obsolete and no longer used by anything in Nixpkgs"; # Added 2024-11-24 boost184 = throw "Boost 1.84 has been removed as it is obsolete and no longer used by anything in Nixpkgs"; # Added 2024-11-24
boost185 = throw "Boost 1.85 has been removed as it is obsolete and no longer used by anything in Nixpkgs"; # Added 2024-11-24 boost185 = throw "Boost 1.85 has been removed as it is obsolete and no longer used by anything in Nixpkgs"; # Added 2024-11-24
boost_process = throw "boost_process has been removed as it is included in regular boost"; # Added 2024-05-01 boost_process = throw "boost_process has been removed as it is included in regular boost"; # Added 2024-05-01
bower2nix = throw "bower2nix has been removed as bower was removed. It is recommended to migrate to yarn."; # Added 2025-09-17
bpb = throw "bpb has been removed as it is unmaintained and not compatible with recent Rust versions"; # Added 2024-04-30 bpb = throw "bpb has been removed as it is unmaintained and not compatible with recent Rust versions"; # Added 2024-04-30
bpftool = throw "'bpftool' has been renamed to/replaced by 'bpftools'"; # Converted to throw 2024-10-17 bpftool = throw "'bpftool' has been renamed to/replaced by 'bpftools'"; # Converted to throw 2024-10-17
brasero-original = lib.warnOnInstantiate "Use 'brasero-unwrapped' instead of 'brasero-original'" brasero-unwrapped; # Added 2024-09-29 brasero-original = lib.warnOnInstantiate "Use 'brasero-unwrapped' instead of 'brasero-original'" brasero-unwrapped; # Added 2024-09-29
@@ -551,6 +552,7 @@ mapAliases {
budgie = throw "The `budgie` scope has been removed and all packages moved to the top-level"; # Added 2024-07-14 budgie = throw "The `budgie` scope has been removed and all packages moved to the top-level"; # Added 2024-07-14
budgiePlugins = throw "The `budgiePlugins` scope has been removed and all packages moved to the top-level"; # Added 2024-07-14 budgiePlugins = throw "The `budgiePlugins` scope has been removed and all packages moved to the top-level"; # Added 2024-07-14
buildBarebox = throw "buildBarebox has been removed due to lack of interest in maintaining it in nixpkgs"; # Added 2025-04-19 buildBarebox = throw "buildBarebox has been removed due to lack of interest in maintaining it in nixpkgs"; # Added 2025-04-19
buildBowerComponents = throw "buildBowerComponents has been removed as bower was removed. It is recommended to migrate to yarn."; # Added 2025-09-17
buildGo122Module = throw "Go 1.22 is end-of-life, and 'buildGo122Module' has been removed. Please use a newer builder version."; # Added 2025-03-28 buildGo122Module = throw "Go 1.22 is end-of-life, and 'buildGo122Module' has been removed. Please use a newer builder version."; # Added 2025-03-28
buildGo123Module = throw "Go 1.23 is end-of-life, and 'buildGo123Module' has been removed. Please use a newer builder version."; # Added 2025-08-13 buildGo123Module = throw "Go 1.23 is end-of-life, and 'buildGo123Module' has been removed. Please use a newer builder version."; # Added 2025-08-13
buildGoPackage = throw "`buildGoPackage` has been deprecated and removed, see the Go section in the nixpkgs manual for details"; # Added 2024-11-18 buildGoPackage = throw "`buildGoPackage` has been deprecated and removed, see the Go section in the nixpkgs manual for details"; # Added 2024-11-18
@@ -877,6 +879,7 @@ mapAliases {
fdr = throw "fdr has been removed, as it cannot be built from source and depends on Python 2.x"; # Added 2025-03-19 fdr = throw "fdr has been removed, as it cannot be built from source and depends on Python 2.x"; # Added 2025-03-19
inherit (luaPackages) fennel; # Added 2022-09-24 inherit (luaPackages) fennel; # Added 2022-09-24
ferdi = throw "'ferdi' has been removed, upstream does not exist anymore and the package is insecure"; # Added 2024-08-22 ferdi = throw "'ferdi' has been removed, upstream does not exist anymore and the package is insecure"; # Added 2024-08-22
fetchbower = throw "fetchbower has been removed as bower was removed. It is recommended to migrate to yarn."; # Added 2025-09-17
fetchFromGithub = throw "You meant fetchFromGitHub, with a capital H"; # preserve, reason: common typo fetchFromGithub = throw "You meant fetchFromGitHub, with a capital H"; # preserve, reason: common typo
ffmpeg_5 = throw "ffmpeg_5 has been removed, please use another version"; # Added 2024-07-12 ffmpeg_5 = throw "ffmpeg_5 has been removed, please use another version"; # Added 2024-07-12
ffmpeg_5-headless = throw "ffmpeg_5-headless has been removed, please use another version"; # Added 2024-07-12 ffmpeg_5-headless = throw "ffmpeg_5-headless has been removed, please use another version"; # Added 2024-07-12

View File

@@ -466,8 +466,6 @@ with pkgs;
python3Packages = python311Packages; python3Packages = python311Packages;
}; };
fetchbower = callPackage ../build-support/fetchbower { };
fetchbzr = callPackage ../build-support/fetchbzr { }; fetchbzr = callPackage ../build-support/fetchbzr { };
fetchcvs = fetchcvs =
@@ -9108,12 +9106,6 @@ with pkgs;
saxon_12-he saxon_12-he
; ;
### DEVELOPMENT / LIBRARIES / JAVASCRIPT
### DEVELOPMENT / BOWER MODULES (JAVASCRIPT)
buildBowerComponents = callPackage ../development/bower-modules/generic { };
### DEVELOPMENT / GO ### DEVELOPMENT / GO
# the unversioned attributes should always point to the same go version # the unversioned attributes should always point to the same go version