Merge pull request #789 from diogox/develop

Add NixOS support
This commit is contained in:
Lea Anthony 2021-09-03 18:55:53 +10:00 committed by GitHub
commit 9efc648e3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 64 additions and 26 deletions

View file

@ -71,6 +71,8 @@ const (
Crux
// RHEL distribution
RHEL
// NixOS distribution
NixOS
)
// DistroInfo contains all the information relating to a linux distribution
@ -183,6 +185,8 @@ func parseOsRelease(osRelease string) *DistroInfo {
result.Distribution = EndeavourOS
case "crux":
result.Distribution = Crux
case "nixos":
result.Distribution = NixOS
default:
result.Distribution = Unknown
}
@ -274,6 +278,18 @@ func PrtGetInstalled(packageName string) (bool, error) {
return exitCode == 0, nil
}
// NixEnvInstalled uses nix-env to see if a package is installed
func NixEnvInstalled(packageName string) (bool, error) {
program := NewProgramHelper()
nixEnv := program.FindProgram("nix-env")
if nixEnv == nil {
return false, fmt.Errorf("cannot check dependencies: nix-env not found")
}
packageName = strings.ReplaceAll(packageName, "+", `\+`)
_, _, exitCode, _ := nixEnv.Run("-q", packageName)
return exitCode == 0, nil
}
// RequestSupportForDistribution promts the user to submit a request to support their
// currently unsupported distribution
func RequestSupportForDistribution(distroInfo *DistroInfo) error {

View file

@ -318,30 +318,50 @@ distributions:
- name: webkit2gtk3-devel
help: Please install with `sudo zypper in webkit2gtk3-devel` and try again
opensuse-leap:
id: opensuse-leap
releases:
default:
version: default
name: openSUSE Leap
gccversioncommand: *gccdumpfullversion
programs: *opensusedefaultprograms
libraries: *opensusedefaultlibraries
id: opensuse-leap
releases:
default:
version: default
name: openSUSE Leap
gccversioncommand: *gccdumpfullversion
programs: *opensusedefaultprograms
libraries: *opensusedefaultlibraries
crux:
id: crux
releases:
default:
version: default
name: Crux Linux
gccversioncommand: *gccdumpversion
programs:
- name: gcc
help: Please install with `sudo prt-get depinst gcc-c++ make` and try again
- name: pkg-config
help: Please install with `sudo prt-get depinst pkg-config` and try again
- name: npm
help: Please install with `sudo prt-get depinst nodejs` and try again
libraries:
- name: gtk3
help: Please install with `sudo prt-get depinst gtk3` and try again
- name: webkitgtk
help: Please install with `sudo prt-get depinst webkitgtk` and try again
id: crux
releases:
default:
version: default
name: Crux Linux
gccversioncommand: *gccdumpversion
programs:
- name: gcc
help: Please install with `sudo prt-get depinst gcc-c++ make` and try again
- name: pkg-config
help: Please install with `sudo prt-get depinst pkg-config` and try again
- name: npm
help: Please install with `sudo prt-get depinst nodejs` and try again
libraries:
- name: gtk3
help: Please install with `sudo prt-get depinst gtk3` and try again
- name: webkitgtk
help: Please install with `sudo prt-get depinst webkitgtk` and try again
nixos:
id: nixos
releases:
default:
version: default
name: NixOS
gccversioncommand: *gccdumpversion
programs:
- name: gcc
help: Please install with `nix-env -iA nixos.gcc`
- name: pkg-config
help: Please install with `nix-env -iA nixos.pkg-config`
- name: npm
help: Please install with `nix-env -iA nixos.nodejs`
libraries:
- name: gtk+3
help: Please install with `nix-env -iA nixos.gtk3`
- name: webkitgtk
help: Please install with `nix-env -iA nixos.nodePackages.webkitgtk`

View file

@ -293,6 +293,8 @@ func CheckDependencies(logger *Logger) (bool, error) {
libraryChecker = EOpkgInstalled
case Crux:
libraryChecker = PrtGetInstalled
case NixOS:
libraryChecker = NixEnvInstalled
default:
return false, RequestSupportForDistribution(distroInfo)
}