-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
568 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
{ | ||
description = "Cross-platform visual development tool and SCPI instrument controller"; | ||
|
||
inputs = { | ||
nixpkgs.url = "nixpkgs/nixos-21.05"; | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nix-filter.url = "github:numtide/nix-filter"; | ||
npmlock2nix = { | ||
url = "github:ilkecan/npmlock2nix/"; | ||
flake = false; | ||
}; | ||
nix-utils.url = "git+https://git.sr.ht/~ilkecan/nix-utils"; | ||
}; | ||
|
||
outputs = { self, nixpkgs, flake-utils, npmlock2nix, ... }@inputs: | ||
let | ||
inherit (builtins) | ||
attrNames | ||
attrValues | ||
; | ||
inherit (nixpkgs.lib) | ||
getAttrs | ||
; | ||
inherit (flake-utils.lib) | ||
defaultSystems | ||
eachSystem | ||
; | ||
nix-filter = inputs.nix-filter.lib; | ||
nix-utils = inputs.nix-utils.lib; | ||
inherit (nix-utils) | ||
createOverlays | ||
getUnstableVersion | ||
; | ||
|
||
supportedSystems = defaultSystems; | ||
commonArgs = { | ||
version = getUnstableVersion self.lastModifiedDate; | ||
homepage = "https://github.com/eez-open/studio"; | ||
downloadPage = "https://github.com/eez-open/studio/releases"; | ||
changelog = null; | ||
maintainers = [ | ||
{ | ||
name = "ilkecan bozdogan"; | ||
email = "[email protected]"; | ||
github = "ilkecan"; | ||
githubId = "40234257"; | ||
} | ||
]; | ||
platforms = supportedSystems; | ||
}; | ||
|
||
derivations = { | ||
eez-studio = import ./nix/eez-studio.nix commonArgs; | ||
}; | ||
in | ||
{ | ||
overlays = createOverlays derivations { | ||
inherit | ||
nix-filter | ||
nix-utils | ||
; | ||
}; | ||
overlay = self.overlays.eez-studio; | ||
} // eachSystem supportedSystems (system: | ||
let | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = attrValues self.overlays ++ [ | ||
(final: prev: { npmlock2nix = import npmlock2nix { pkgs = prev; }; }) | ||
]; | ||
}; | ||
|
||
packageNames = attrNames derivations; | ||
in | ||
rec { | ||
checks = packages; | ||
|
||
packages = getAttrs packageNames pkgs; | ||
defaultPackage = packages.eez-studio; | ||
|
||
hydraJobs = { | ||
build = packages; | ||
}; | ||
|
||
devShell = | ||
let | ||
packageList = attrValues packages; | ||
in | ||
pkgs.mkShell { | ||
packages = packageList; | ||
|
||
shellHook = '' | ||
$(${defaultPackage.preConfigure}) || true | ||
export PATH=./node_modules/.bin:$PATH | ||
''; | ||
}; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ version | ||
, homepage | ||
, downloadPage | ||
, changelog | ||
, maintainers | ||
, platforms | ||
}: | ||
{ lib | ||
, electron | ||
, makeWrapper | ||
, nix-filter | ||
, nix-utils | ||
, nodejs | ||
, npmlock2nix | ||
, stdenv | ||
, symlinkJoin | ||
, ... | ||
}@pkgs: | ||
|
||
let | ||
inherit (builtins) | ||
concatStringsSep | ||
map | ||
; | ||
inherit (lib) importJSON; | ||
inherit (nix-utils) getPatches; | ||
inherit (npmlock2nix.internal) add_node_modules_to_cwd; | ||
inherit (nix-filter) inDirectory; | ||
inherit (import ./electron-lib.nix pkgs) | ||
electronBuilderUnpackedDirname | ||
getElectronExecutable | ||
symlinkElectron | ||
; | ||
|
||
# Reading the files in the filtered directory is not possible right now. | ||
# Follow up on how https://github.com/NixOS/nix/pull/5163 will be resolved. | ||
src = ./..; | ||
packageJson = importJSON "${toString src}/package.json"; | ||
pname = packageJson.name; | ||
mainProgram = pname; | ||
|
||
symlinkedElectron = symlinkElectron electron; | ||
|
||
nm = import ./node_modules.nix { | ||
inherit src nodejs; | ||
electron = symlinkedElectron; | ||
} pkgs; | ||
in | ||
|
||
stdenv.mkDerivation { | ||
inherit pname version; | ||
|
||
src = nix-filter { | ||
root = src; | ||
include = [ | ||
"gulpfile.js" | ||
"icon.icns" | ||
"icon.ico" | ||
"package-lock.json" | ||
"package.json" | ||
"resources/expression-grammar.pegjs" | ||
"tsconfig.json" | ||
(inDirectory "installation") | ||
(inDirectory "libs") | ||
(inDirectory "packages") | ||
]; | ||
name = pname; | ||
}; | ||
|
||
NO_UPDATE_NOTIFIER = 1; | ||
|
||
buildInputs = [ nm.out ]; | ||
|
||
nativeBuildInputs = [ | ||
makeWrapper.out | ||
]; | ||
|
||
patches = getPatches ./patches; | ||
|
||
# couldn't make it work with symlink. may be related to this | ||
# https://github.com/microsoft/TypeScript/issues/29518 | ||
# although the error is different | ||
preConfigure = add_node_modules_to_cwd nm "copy"; | ||
|
||
buildPhase = | ||
let | ||
extraResources = import ./extra-resources { inherit lib; }; | ||
|
||
createSymlink = target: linkName: "ln -s ${target} ${linkName}"; | ||
symlinkEach = files: | ||
let | ||
lines = map ({ filename, storePath }: createSymlink storePath filename) files; | ||
in | ||
concatStringsSep "\n" lines; | ||
in | ||
'' | ||
extraResourcesPath="installation/extra-resources" | ||
mkdir -p $extraResourcesPath | ||
pushd $extraResourcesPath | ||
${symlinkEach extraResources} | ||
popd | ||
npm run build | ||
npx --no-install electron-builder \ | ||
--config.electronVersion="${electron.version}" \ | ||
--config.electronDist="${symlinkedElectron}/lib/electron" \ | ||
--dir | ||
''; | ||
|
||
installPhase = '' | ||
mkdir -p $out/lib/${pname} | ||
resourcesDir=$out/lib/${pname}/resources | ||
mv ./dist/${electronBuilderUnpackedDirname}/resources $resourcesDir | ||
mkdir -p $out/bin | ||
makeWrapper '${getElectronExecutable electron}' "$out/bin/${mainProgram}" \ | ||
--set ELECTRON_RESOURCES_PATH $resourcesDir \ | ||
--add-flags "$resourcesDir/app.asar" | ||
''; | ||
|
||
meta = { | ||
description = packageJson.description; | ||
longDescription = | ||
"The EEZ Studio is an open source cross-platform modular visual tool" + | ||
"aimed to address various programming and management tasks for EEZ BB3" + | ||
"open source T&M chassis and EEZ H24005 programmable power supply and" + | ||
"other T&M devices that support SCPI from manufacturers such as" + | ||
"Keysight, Rigol, Siglent, etc."; | ||
|
||
inherit homepage downloadPage changelog; | ||
|
||
license = lib.licenses.gpl3Only; | ||
inherit maintainers mainProgram platforms; | ||
}; | ||
} |
Oops, something went wrong.