Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 8d45371

Browse files
committed
fix: adds haskell packages to db
1 parent 7496b24 commit 8d45371

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/nix.ts

+17-4
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,16 @@ export async function update (channels: string | Array<string> = [], last: boole
8282

8383
let channel = channels
8484

85-
// Get list of avalaible packages in the nixster channel and put them in the database
85+
// Get list of available packages in the channel and put them in the database
8686
console.log(`Querying channel ${channel} for available packages`)
8787
let pkgs: any = {}
8888
const args = ['--query', `--file`, `channel:${channel}`, '--available', '--meta', '--json']
8989
// For some reason, in order to get R packages it is necessary to explicitly use --attr rPackages
9090
// so we have a loop for that case and potential others
9191
for (let extraArgs of [
9292
[],
93-
['--attr', 'rPackages']
93+
['--attr', 'rPackages'],
94+
['--attr', 'haskellPackages']
9495
]) {
9596
let allArgs = args.concat(extraArgs)
9697
let json = await spawn('nix-env', allArgs)
@@ -136,12 +137,21 @@ export async function update (channels: string | Array<string> = [], last: boole
136137
}
137138

138139
// Rename language packages to provide consistency and
139-
// prevent versioned names.
140+
// across languages
141+
142+
const haskellPackage = attr.match(/^haskellPackages\./)
143+
if (haskellPackage) {
144+
type = 'haskell-package'
145+
// Prefix package names with `haskell`
146+
name = 'haskell-' + name
147+
}
140148

141149
const pythonPackage = attr.match(/^python(\d+)Packages\./)
142150
if (pythonPackage) {
143151
type = 'python-package'
144152
runtime = 'python' + pythonPackage[1]
153+
// Prefix package names with `python`
154+
// removing the Python version if necessary
145155
if (name.startsWith('python')) {
146156
name = name.replace(/^python[\d\.]+/, 'python')
147157
} else {
@@ -153,6 +163,8 @@ export async function update (channels: string | Array<string> = [], last: boole
153163
if (perlPackage) {
154164
type = 'perl-package'
155165
runtime = 'perl' + (perlPackage[1] ? perlPackage[1] : '')
166+
// Prefix package names with `perl`
167+
// removing the Perl version if necessary
156168
if (name.startsWith('perl')) {
157169
name = name.replace(/^perl[\d\.]+/, 'perl')
158170
}
@@ -161,9 +173,10 @@ export async function update (channels: string | Array<string> = [], last: boole
161173
const rPackage = attr.match(/^rPackages\./)
162174
if (rPackage) {
163175
type = 'r-package'
176+
// R packages are already prefixed with `r-`
164177
}
165178

166-
// Normalise name
179+
// Normalize name
167180
name = name.toLowerCase().replace(/[._-]+/gi, '-')
168181

169182
// Insert row into table

0 commit comments

Comments
 (0)