Pull in jlink from flake, add allowUnfreePreeicate

This commit is contained in:
Artemis Tosini 2023-12-02 01:21:16 +00:00
parent 67a3e18a89
commit 0af4735824
Signed by: artemist
GPG key ID: EE5227935FE3FF18
7 changed files with 55 additions and 115 deletions

View file

@ -1,57 +0,0 @@
{ stdenv, lib, fetchurl, autoPatchelfHook, fontconfig, freetype, libusb, libICE
, libSM, ncurses5, udev, libX11, libXext, libXcursor, libXfixes, libXrender
, libXrandr }:
let
conf = (lib.importJSON ./version.json).${stdenv.hostPlatform.system} or (throw
"unsupported system ${stdenv.hostPlatform.system}");
in stdenv.mkDerivation rec {
pname = "jlink";
version = conf.version;
src = fetchurl { inherit (conf) url hash curlOpts; };
dontConfigure = true;
dontBuild = true;
dontStrip = true;
preferLocalBuild = true;
nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [
fontconfig
freetype
libusb
libICE
libSM
ncurses5
udev
libX11
libXext
libXcursor
libXfixes
libXrender
libXrandr
];
runtimeDependencies = [ udev ];
installPhase = ''
mkdir -p $out/{JLink,bin}
cp -R * $out/JLink
ln -s $out/JLink/J* $out/bin/
install -D -t $out/lib/udev/rules.d 99-jlink.rules
'';
preFixup = ''
patchelf --add-needed libudev.so.1 $out/JLink/libjlinkarm.so
'';
passthru.updateScript = ./update.py;
meta = with lib; {
homepage = "https://www.segger.com/downloads/jlink";
description = "SEGGER J-Link";
license = licenses.unfree;
platforms = [ "x86_64-linux" "i686-linux" "armv7l-linux" "aarch64-linux" ];
maintainers = with maintainers; [ artemist ];
};
}

View file

@ -1,43 +0,0 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ beautifulsoup4 requests lxml ] )" nix-prefetch
import requests
import bs4
import json
import subprocess
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
URL_FORMAT = 'https://www.segger.com/downloads/jlink/JLink_Linux_V{version}_{arch}.tgz'
CURL_OPTS = '-d accept_license_agreement=accepted -d submit=Download+software'
page = requests.get('https://www.segger.com/downloads/jlink').text
elem = bs4.BeautifulSoup(page, features='lxml').find(
'select', {'class': 'version'}).find('option')
version = elem.children.__next__().lstrip('V')
arches = [
('x86_64-linux', 'x86_64'),
('i686-linux', 'i686'),
('armv7l-linux', 'arm'),
('aarch64-linux', 'arm64')
]
out_obj = {}
for nix_arch, jlink_arch in arches:
url = URL_FORMAT.format(version=version.replace('.', ''), arch=jlink_arch)
out = subprocess.run(
['nix-prefetch', f'{{fetchurl}}: fetchurl {{ url = "{url}"; curlOpts = "{CURL_OPTS}"; }}'], stdout=subprocess.PIPE, check=True)
file_hash = out.stdout.decode('utf8').strip()
out_obj[nix_arch] = {
'url': url,
'version': version,
'curlOpts': CURL_OPTS,
'hash': file_hash
}
out_file = open(os.path.join(BASE_DIR, 'version.json'), 'w')
json.dump(out_obj, out_file)
out_file.close()

View file

@ -1 +0,0 @@
{"x86_64-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V792m_x86_64.tgz", "version": "7.92m", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "hash": "sha256-BuLwiszQfdQJdTdMUbOqflYG4zU3HHMDf+JejvIQkps="}, "i686-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V792m_i686.tgz", "version": "7.92m", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "hash": "sha256-QOdjOlBGqKKuOzYpKE2p6P1mBimXzxE2oKB0iWbp440="}, "armv7l-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V792m_arm.tgz", "version": "7.92m", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "hash": "sha256-KUpP6aNh7e3HA/X3Mov3nz3didcKMUaIAaFA5cYd2Kg="}, "aarch64-linux": {"url": "https://www.segger.com/downloads/jlink/JLink_Linux_V792m_arm64.tgz", "version": "7.92m", "curlOpts": "-d accept_license_agreement=accepted -d submit=Download+software", "hash": "sha256-hF3cBCRDRwvVudafOFFdD0pEIjoYWjiJtVz7vgtclx8="}}

View file

@ -1,5 +1,28 @@
{ {
"nodes": { "nodes": {
"artemist": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": [
"utils"
]
},
"locked": {
"lastModified": 1701478627,
"narHash": "sha256-sld299pt7u7y8I86LgglYly7nfBf44oP2N354Ta4t5k=",
"ref": "refs/heads/canon",
"rev": "b78b8efaac4eebc5f9d33dfac3b4a9a4d326b7c5",
"revCount": 15,
"type": "git",
"url": "https://git.mildlyfunctional.gay/artemist/packages.git"
},
"original": {
"type": "git",
"url": "https://git.mildlyfunctional.gay/artemist/packages.git"
}
},
"beautysh": { "beautysh": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -143,11 +166,11 @@
"rev": "a5002a6881b40efbc91829a990a8e11983105db9", "rev": "a5002a6881b40efbc91829a990a8e11983105db9",
"revCount": 3, "revCount": 3,
"type": "git", "type": "git",
"url": "https://git.mildlyfunctional.gay/artemist/fonts" "url": "https://git.mildlyfunctional.gay/artemist/fonts.git"
}, },
"original": { "original": {
"type": "git", "type": "git",
"url": "https://git.mildlyfunctional.gay/artemist/fonts" "url": "https://git.mildlyfunctional.gay/artemist/fonts.git"
} }
}, },
"gitignore": { "gitignore": {
@ -495,6 +518,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"artemist": "artemist",
"fonts": "fonts", "fonts": "fonts",
"home-manager": "home-manager", "home-manager": "home-manager",
"jovian": "jovian", "jovian": "jovian",

View file

@ -3,8 +3,13 @@
nixos-hardware.url = "github:nixos/nixos-hardware"; nixos-hardware.url = "github:nixos/nixos-hardware";
utils.url = "github:numtide/flake-utils"; utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
artemist = {
url = "git+https://git.mildlyfunctional.gay/artemist/packages.git";
inputs.nixpkgs.follows = "nixpkgs";
inputs.utils.follows = "utils";
};
fonts = { fonts = {
url = "git+https://git.mildlyfunctional.gay/artemist/fonts"; url = "git+https://git.mildlyfunctional.gay/artemist/fonts.git";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "utils"; inputs.flake-utils.follows = "utils";
}; };
@ -34,7 +39,6 @@
jovian = { jovian = {
url = "github:jovian-experiments/jovian-nixos"; url = "github:jovian-experiments/jovian-nixos";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
private.url = private.url =
@ -77,15 +81,10 @@
modules = [ ./system/mistmane ]; modules = [ ./system/mistmane ];
}; };
} // utils.lib.eachDefaultSystem (system: } // utils.lib.eachDefaultSystem (system:
let let pkgs = import nixpkgs { inherit system; };
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in { in {
formatter = pkgs.nixfmt; formatter = pkgs.nixfmt;
packages = { packages = {
jlink = pkgs.callPackage ./externals/packages/jlink { };
nvim = inputs.nixvim.legacyPackages."${system}".makeNixvimWithModule { nvim = inputs.nixvim.legacyPackages."${system}".makeNixvimWithModule {
extraSpecialArgs = { inherit inputs; }; extraSpecialArgs = { inherit inputs; };
module = import ./sets/nvim.nix { module = import ./sets/nvim.nix {

View file

@ -21,12 +21,31 @@
settings.trusted-users = [ "artemis" ]; settings.trusted-users = [ "artemis" ];
}; };
nixpkgs = {
overlays = [ inputs.artemist.overlays.default ];
config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"1password"
"brscan5"
"brscan5-etc-files"
"corefonts"
"google-chrome"
"jlink"
"makemkv"
"steamdeck-hw-theme"
"steam"
"steam-jupiter-original"
"steam-original"
"steam-run"
"unrar"
];
};
console = { console = {
keyMap = "us"; keyMap = "us";
earlySetup = true; earlySetup = true;
}; };
nixpkgs.config.allowUnfree = true;
time.timeZone = "Etc/UTC"; time.timeZone = "Etc/UTC";
environment.shellAliases.cp = "cp --reflink=auto --sparse=always"; environment.shellAliases.cp = "cp --reflink=auto --sparse=always";
networking.firewall.enable = false; networking.firewall.enable = false;

View file

@ -1,6 +1,4 @@
{ config, pkgs, ... }: { pkgs, ... }: {
let jlink = pkgs.callPackage ../externals/packages/jlink { };
in {
services.udev.packages = [ services.udev.packages = [
(pkgs.callPackage ../externals/rules/adafruit.nix { }) (pkgs.callPackage ../externals/rules/adafruit.nix { })
(pkgs.callPackage ../externals/rules/limesuite.nix { }) (pkgs.callPackage ../externals/rules/limesuite.nix { })
@ -19,6 +17,7 @@ in {
platformio platformio
proxmark3-rrg proxmark3-rrg
pulseview pulseview
pyocd
stlink stlink
]; ];