I created the following module services/invidious.nix
{ pkgs, stdenv, ... }:
stdenv.mkDerivation {
name = "invidious";
container = pkgs.dockerTools.buildLayeredImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/bash" ];
Env = [];
Volumes = {};
};
};
}
My eventual goal is to have several services in modules and use nix-build to build each of those services as containers, and write the resulting image names to a file:
let
config = import ./config.nix;
pkgs = config.pkgs;
invidious = import ./services/invidious.nix;
in rec {
serviceimages = pkgs.writeText "images.txt" ''
${invidious(pkgs)}
'';
}
and my config.nix just has the pkgs pinned version:
{
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
}
However, when I use nix-build, I get the following error:
nix-build services.nix -A serviceimages
these 2 derivations will be built:
/nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv
/nix/store/4x31hx9nxcbbksi2hsim08djrsj4h1zh-images.txt.drv
building '/nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv'...
unpacking sources
variable $src or $srcs should point to the source
error: builder for '/nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv' failed with exit code 1;
last 2 log lines:
> unpacking sources
> variable $src or $srcs should point to the source
For full logs, run 'nix log /nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv'.
If I try to pull the full logs using the command given, I get the following:
nix log /nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override
...and if I enable the experimental feature, I see the following:
nix --extra-experimental-features nix-command log /nix/store/dbl3bzc05pssq3q9g8wd2i92xpmwf5bb-invidious.drv
#nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
variable $src or $srcs should point to the source
If I just try to build the same service in a single file, it successfully builds the image:
let
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
in rec {
docker = pkgs.dockerTools.buildLayeredImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/sh" ];
Env = [];
Volumes = {};
};
};
results = pkgs.writeText "images.txt" ''
${docker}
'';
}
What am I doing wrong with my attempt to use modules?
I figured it out. I didn't need the mkDerivation. I just need the buildLayeredImage
{ pkgs, ... }:
pkgs.dockerTools.buildLayeredImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/bash" ];
Env = [];
Volumes = {};
};
}
The service.nix and config.nix stay the same:
let
config = import ./config.nix;
pkgs = config.pkgs;
invidious = import ./services/invidious.nix;
in rec {
serviceimages = pkgs.writeText "images.txt" ''
${invidious(pkgs)}
'';
}
{
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
}
Related
I'm using jpackage to convert the jar file to an exe, with the exe file provided by the internal JRE. As a result of the conversion, good results were obtained, the JRE weighs about 38.5 mb.
When I run the exe, the GUI quality is twice as WORSE as in a normal jar! In addition, the window of the new exe file increases on its own. Thus, very strange changes appear, as if the exe file is trying to imitate a window jar file. I want to point out that I am using libGdx for the GUI.
desktop gradle:
{
plugins { id 'org.beryx.runtime' version '1.8.4' }
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = ["src/"]
sourceSets.main.resources.srcDirs = ["../android/assets"]
mainClassName = "com.iapp.chess.desktop.DesktopLauncher"
def osName = System.getProperty('os.name').toLowerCase(Locale.ROOT)
project.ext.assetsDir = new File("../android/assets")
task runGame(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
destinationDirectory = file("$buildDir/lib")
}
jpackageImage.dependsOn dist
dist.dependsOn classes
eclipse.project.name = appName + "-desktop"
runtime {
options = ['--strip-debug',
'--compress', '2',
'--no-header-files',
'--no-man-pages',
'--strip-native-commands',
'--vm', 'server']
modules = ['java.base',
'java.desktop',
'jdk.unsupported']
distDir = file(buildDir)
jpackage {
jpackageHome = 'C:\\Program Files\\Java\\jdk-17.0.2'
mainJar = dist.archiveFileName.get()
if (osName.contains('windows')) {
imageOptions = ["--icon", file("../icons/icon.ico")]
} else if (osName.contains('linux')) {
imageOptions = ["--icon", file("../icons/icon.png")]
} else if (osName.contains('mac')) {
imageOptions = ["--icon", file("../icons/icon.icns")]
}
}
}
}
I am creating a VsCode extension which provides inline completions. Currently, it can be accessed using the default "Trigger Suggest" command. I want it to be different, as it should be different from the default option. The main code looks like this:
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
const command = 'getairesponse';
const files = ['c','cpp','csharp','java','javascript', 'php', 'python', 'SQL', 'HTML', 'plaintext'];
const provider1 = vscode.languages.registerCompletionItemProvider(files, {
async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, context: vscode.CompletionContext) {
var editor = vscode.window.activeTextEditor;
if (editor){
var cursorPosition = editor.selection.active;
var input = editor.document.getText(new vscode.Range(0, 0, cursorPosition.line, cursorPosition.character));
var out = getOutput(input);
const simpleCompletion = new vscode.CompletionItem(await out);
return [simpleCompletion];
}
}
});
context.subscriptions.push(provider1);
}
I want the command for the extension to be equal to the constant command. I have also included the command in the package.json file:
"contributes": {
"commands": [
{
"command": "getairesponse",
"title": "Get AI Response"
}
]
}
How can I get a list of all commits between two revisions in AWS CodeCommit, using the SDK or AWS CLI?
Essentially, what I need is an AWS CodeCommit way to git log a..b
There's a batch-get-commits method, but that requires a list with all the commit ids.
If you call getCommit, there is a parents field in the response, which you can use to retreive the previous commit.
const AWS = require('aws-sdk')
const codecommit = new AWS.CodeCommit()
const commitIdFrom = 'commit hash'
const commitIdTo = 'commit hash'
const repositoryName = 'your repo name'
let keepRetrievingCommits = true
let commitId = commitIdTo
const commits = []
while (keepRetrievingCommits) {
try {
const params = { commitId, repositoryName }
const ccData = await codecommit.getCommit(params).promise()
const { author, message, parents } = ccData.commit
commits.push({
repositoryName,
commitId,
author: author.email,
message
})
if(parents.length === 1) {
commitId = parents[0]
}
else {
keepRetrievingCommits = false
}
if(commitId === commitIdFrom) { // won't include info of 'commitFrom'
keepRetrievingCommits = false
}
} catch(err) {
console.error(`Error while getting commit details ${commitId} on repo ${repositoryName}: ${JSON.stringify(err)}`)
}
}
// commitsData.forEach(...)
My terraform file looks like this:
resource "google_compute_instance" "virtual_instance" {
name = "${var.instance_name}"
machine_type = "${var.instance_type}"
zone = "${var.zone}"
lifecycle {
ignore_changes = ["boot_disk.0.initialize_params.0.image"]
}
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-1604-lts"
size = "30"
type = "pd-standard"
}
}
network_interface {
network = "default"
access_config {}
}
attached_disk {
source = "${google_compute_disk.managed_data_disk.name}"
mode = "READ_WRITE"
}
metadata {
}
}
This above code created the instance. But when i change then network_interface block as mentioned below
network_interface {
network = "${module.vpc.vpc_name}"
subnetwork = "${module.vpc.subnet_name}"
access_config {}
}
The VPC module is :
resource "google_compute_network" "vpc" {
name = "${var.name}-vpc"
auto_create_subnetworks = "false"
}
resource "google_compute_subnetwork" "subnet_public" {
name = "${var.subnet_name_public}"
ip_cidr_range = "${var.subnet_cidr_public}"
network = "${var.name}-vpc"
depends_on = ["google_compute_network.vpc"]
region = "${var.region}"
}
resource "google_compute_firewall" "firewall" {
name = "${var.name}-firewall"
network = "${google_compute_network.vpc.name}"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["22"]
}
source_ranges = ["0.0.0.0/0"]
}
when I changed into network_interface to custom values. It's throwing the error is
google_compute_instance.virtual_instance: Error creating network interfaces: exactly one of network or subnetwork must be provided
Please help me on this
Advance Thanks to #ydaetskcoR. If you choose custom values of network_interface. You can't mention both network and subnetwork. You will choose only subnetwork values mentioned below.
network_interface {
subnetwork = "${module.vpc.subnet_name}"
access_config {}
}
I would like to define separate settings for different environments:
env {
qa {
fass_url = "https://..."
client_id = "1111"
}
uat {
fass_url = "https://www...."
client_id = "2222"
}
}
How to load those settings for different environment? The following code does not work:
private[this] val config = ConfigFactory.load()
val env_sett = "qa"
val env = if (env_sett == "qa") "env_qa"
else if (env_sett == "uat") "env_uat"
else "env_test_uat"