Cannot override notion with package from unstable - nix

The latest version of notion is available in the unstable branch. I want my install of nixos 17.03 to use it. Here is my configuration.
I override notion with pkgsUnstable.notion.
nixpkgs.config = {
allowUnfree = true;
packageOverrides = let pkgsUnstable = import (
fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz
) { }; in pkgs:
rec {
visualvm = pkgsUnstable.visualvm;
notion = pkgsUnstable.notion;
};
};
And I added notion to environment.systemPackages. I also have services.xserver.winowManager.notion.eable = true;
With this setup I can get visualvm updated from unstable but when I check the version of notion with notion -version I get 3-2015061300. It should be 3-2017050501.
How can I get the updated version of notion?

Related

How can I override a package source in Nix?

So I want to replace pkgs.picom in my home-manager config with a newer fork. How can I do that?
I have a feeling it's something like:
let newPicom = pkgs.picom.override.src.url = "https://github.com/ibhagwan/picom";
in
services.picom.package = newPicom;
But knowing Nix is probably actually some really long incantation with self: super: and so on.
nixos.wiki has an example of overriding the source of a package.
You do need to provide a reproducible source. A github repo url is mutable, so you need to specify the revision.
{ pkgs, ... }:
let newPicom = pkgs.picom.overrideAttrs (old: {
version = "git"; # usually harmless to omit
src = /* put your source here; typically a local path or
a fixed-output derivation produced by
`fetchFromGitHub`.
builtins.fetchGit is also an option. Doesn't run
in parallel but does fetch private sources. */;
});
in {
services.picom.package = newPicom;
}
Overlays
let
picom_overlay = (self: super: {
picom = super.picom.overrideAttrs (prev: {
version = "git";
src = pkgs.fetchFromGitHub {
owner = "yshui";
repo = "picom";
rev = "31e58712ec11b198340ae217d33a73d8ac73b7fe";
sha256 = pkgs.lib.fakeSha256;
};
});
});
in
nixpkgs.overlays = [ picom_overlay ];
Of course, sha256 should be replaced with the relevant hash shown in the output error after building -- in this case:
sha256 = "sha256-VBnIzisg/7Xetd/AWVHlnaWXlxX+wqeYTpstO6+T5cE=";
picom-next
Note that there is also a picom-next package so one can alternatively do:
let
picom_overlay = (self: super: {
picom = super.picom.overrideAttrs (oldAttrs: rec {
inherit (super.picom-next) pname version src;
});
});
in
nixpkgs.overlays = [ picom_overlay ];
Or more simply with #RobertHensing's suggestion:
services.picom.package = pkgs.picom-next;

How can I enable Caddy plugins in NixOS?

I've just started playing with NixOS, and have so far managed to edit /etc/nixos/configuration.nix in my NixOS 18.09 VM to have PHP-FPM and the Caddy webserver enabled.
{ config, pkgs, ... }:
{
imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
users = {
mutableUsers = false;
groups = {
caddy = { };
php-project = { };
};
users = {
hello = {
group = "php-project";
};
};
};
environment.systemPackages = [
pkgs.htop
pkgs.httpie
pkgs.php # for PHP CLI
];
services.caddy = {
enable = true;
email = "david#example.com";
agree = true;
config = ''
(common) {
gzip
header / -Server
header / -X-Powered-By
}
:8080 {
root /var/www/hello
fastcgi / /run/phpfpm/hello.sock php
log syslog
import common
}
'';
};
services.phpfpm = {
phpOptions = ''
date.timezone = "Europe/Berlin"
'';
poolConfigs = {
hello = ''
user = hello
listen = /run/phpfpm/hello.sock
; ...
pm.max_requests = 500
'';
};
};
}
A PHP-processed response is available at at localhost:8080. (Yay!)
To enable Caddy plugins when compiling from source, Go imports are added to caddy's run.go, e.g.:
_ "github.com/mholt/caddy/caddyhttp" // plug in the HTTP server type
// This is where other plugins get plugged in (imported)
_ "github.com/nicolasazrak/caddy-cache" // added to use another plugin
)
How can I set such line insertion to be performed after the source is downloaded and before the build takes place? (If this is a reasonable approach when using Nix?)
The NixOS 18.09 caddy package.
The NixOS 18.09 caddy service.
I believe that when writing a package a builder script (Bash or otherwise) can be assigned, and I'm thinking the line insertion could be done in it. But I'm lost as to how to assign a script to an existing package in this situation (override an attribute/use an overlay?) and where to put the script on the disk.
Status update
I've been doing some reading on customising packages in general and it sounds like overlays might be what I need. However, I don't seem to be able to get my overlay evaluated.
I'm using overriding of the package name as a test as it's simpler than patching code.
Overlay attempt 1
/etc/nixos/configuration.nix:
{ config, pkgs, options, ... }:
{
imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
nix.nixPath = options.nix.nixPath.default ++ [
"nixpkgs-overlays=/etc/nixos/overlays-compat/"
];
# ...
}
/etc/nixos/overlays-compat/overlays.nix:
self: super:
with super.lib;
let
# Using the nixos plumbing that's used to evaluate the config...
eval = import <nixpkgs/nixos/lib/eval-config.nix>;
# Evaluate the config,
paths = (eval {modules = [(import <nixos-config>)];})
# then get the `nixpkgs.overlays` option.
.config.nixpkgs.overlays
;
in
foldl' (flip extends) (_: super) paths self
/etc/nixos/overlays-compat/caddy.nix:
self: super:
{
caddy = super.caddy.override {
name = "caddy-override";
};
}
Overlay attempt 2
/etc/nixos/configuration.nix:
nixpkgs.overlays = [ (self: super: {
caddy = super.caddy.override {
name = "caddy-override";
};
} ) ];
error: anonymous function at /nix/store/mr5sfmz6lm5952ch5q6v49563wzylrkx-nixos-18.09.2327.37694c8cc0e/nixos/pkgs/servers/caddy/default.nix:1:1 called with unexpected argument 'name', at /nix/store/mr5sfmz6lm5952ch5q6v49563wzylrkx-nixos-18.09.2327.37694c8cc0e/nixos/lib/customisation.nix:69:12
overrideAttrs
I previously managed to override the package name with this:
{ config, pkgs, options, ... }:
let
caddyOverride = pkgs.caddy.overrideAttrs (oldAttrs: rec {
name = "caddy-override-v${oldAttrs.version}";
});
in {
{
# ...
services.caddy = {
package = caddyOverride;
# ...
}
}
I could see in htop that the caddy binary was in a folder called /nix/store/...-caddy-override-v0.11.0-bin/. But I understand that overriding in this way has been superseded by overlays.
In order to add plugins to Caddy, it seems that the method is to modify the source.
You will need to adapt the Nixpkgs expression for Caddy to make that possible. That can be done outside the Nixpkgs tree, using services.caddy.package = callPackage ./my-caddy.nix {} for example, or by forking the Nixpkgs repository and pointing your NIX_PATH to your clone.
There is an issue for Caddy plugins: https://github.com/NixOS/nixpkgs/issues/14671
PR welcome!

NixOS: Install unfree package using different channel

I am using the default nixos 17.09 channel and want to install an unfree package from the unstable channel.
I am using (import <nixos-unstable> {}).vscode to install vscode in this case, but I am getting the error that I must set ...allowUnfree = true;
It seems that the setting only applies to the default channel.
How can I set allowFree = true; also on the unstable channel?
I found a solution (https://github.com/NixOS/nixpkgs/issues/25880#issuecomment-322855573).
It creates an alias for the unstable channel with the same config.
nixpkgs.config =
{
# Allow proprietary packages
allowUnfree = true;
# Create an alias for the unstable channel
packageOverrides = pkgs:
{
unstable = import <nixos-unstable>
{
# pass the nixpkgs config to the unstable alias
# to ensure `allowUnfree = true;` is propagated:
config = config.nixpkgs.config;
};
};
};
Then you can use it like unstable.vscode instead of (import <nixos-unstable> {}).vscode.
As an alternative example:
{ config, pkgs, ... }:
let
unstable = import <unstable> {
config = config.nixpkgs.config;
};
in
{
environment.systemPackages = with pkgs; [
# google-chrome
unstable.google-chrome
];
nixpkgs.config.allowUnfree = true;
}

TFS Build 2.0 C#, howto add variables to the build/Pass Msbuild args

I am trying to pass arguments to MSBuild 2.0. After research it appears that I need to do this using variables, but I cannot figure out how to incorporate this into my queue request below. I have tried parameters but that does not seem to work. Here is what I am trying to tell MSBuild #" /p:OctoPackPackageVersion=" + releaseNumber. This worked with the XAML build using IBuildRequest.ProcessParameters.
var buildClient = new BuildHttpClient(new Uri(collectionURL), new
VssCredentials(true));
var res = await buildClient.QueueBuildAsync(new Build
{
Definition = new DefinitionReference
{
Id = targetBuild.Id
},
Project = targetBuild.Project,
SourceVersion = ChangeSetNumber,
Parameters = buildArg
});
return res.Id.ToString();
vNext build system is different with legacy XAML build system, you cannot pass variable to build tasks in the build definition directly when queue the build. The code you used updated the build definition before queue the build which means that the build definition may keep changing if the variable changed.
The workaround for this would be add a variable in your build definition for example "var1" and then use this variable as the arguments for MSBuild Task:
With this, you will be able to pass the value to "var1" variable when queue the build without updating the build definition.
Build build = new Build();
build.Parameters = "{\"var1\":\"/p:OctoPackPackageVersion=version2\"}";
// OR using Newtonsoft.Json.JsonConvert
var dict = new Dictionary<string, string>{{"var1", "/p:OctoPackPackageVersion=version2"}};
build.Parameters = JsonConvert.SerializeObject(dict)
I have found this solution and it works for me excellent. I set custom parameters for convenience in build definition without updating on server:
foreach (var variable in targetBuildDef.Variables.Where(p => p.Value.AllowOverride))
{
var customVar = variables.FirstOrDefault(p => p.Key == variable.Key);
if (customVar == null)
continue;
variable.Value.Value = customVar.Value.TrimEnd('\\');
}
And then set variables values in build parameters:
using (TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(new Uri(tFSCollectionUri)))
{
using (BuildHttpClient buildServer = ttpc.GetClient<BuildHttpClient>())
{
var requestedBuild = new Build
{
Definition = targetBuildDef,
Project = targetBuildDef.Project
};
var dic = targetBuildDef.Variables.Where(z => z.Value.AllowOverride).Select(x => new KeyValuePair<string, string>(x.Key, x.Value.Value));
var paramString = $"{{{string.Join(",", dic.Select(p => $#"""{p.Key}"":""{p.Value}"""))}}}";
var jsonParams = HttpUtility.JavaScriptStringEncode(paramString).Replace(#"\""", #"""");
requestedBuild.Parameters = jsonParams;
var queuedBuild = buildServer.QueueBuildAsync(requestedBuild).Result;
First, the new build on TFS2015 which is called vNext build not MSbuild 2.0.
Which you are looking for should be Build variables. Variables give you a convenient way to get key bits of data into various parts of your build process. For the variable with Allow at queue time box checked you could be enable allow your team to modify the value when they manually queue a build.
Some tutorials may be helpful for using variables:
TFS Build 2015 (vNext) – Scripts and Variables
Passing Visual Studio Team Services build properties to MSBuild
Patrick, I was able to find a work around to my issue by updating the build definition. This is definitely not ideal but it works. As you can see below I am trying to add to the msbuild args already present. If you know a better way let me know. I really appreciate you taking the time to look at my question.
public static async Task<string> QueueNewBuild(string project, BuildDefinitionReference targetBuild, string collectionURL, string ChangeSetNumber, string ReleaseNumber, bool CreateRelease)
{
var buildClient = new BuildHttpClient(new Uri(collectionURL), new VssCredentials(true));
await Task.Delay(1000).ConfigureAwait(false);
var buildDef = await buildClient.GetDefinitionAsync(targetBuild.Project.Id, targetBuild.Id);
BuildDefinitionVariable OrigMSbuildvar = buildDef.Variables["MSBuildArgs"];
buildDef.Variables["MSBuildArgs"].Value = OrigMSbuildvar.Value + " /p:OctoPackPackageVersion=" + ReleaseNumber.ToString();
await Task.Delay(1000).ConfigureAwait(false);
buildDef = await buildClient.UpdateDefinitionAsync(buildDef);
await Task.Delay(1000).ConfigureAwait(false);
Build build = new Build
{
Definition = new DefinitionReference
{
Id = targetBuild.Id
},
Project = targetBuild.Project,
SourceVersion = ChangeSetNumber
};
await Task.Delay(1000).ConfigureAwait(false);
var res = await buildClient.QueueBuildAsync(build);
buildDef.Variables["MSBuildArgs"].Value = OrigMSbuildvar.Value;
await Task.Delay(1000).ConfigureAwait(false);
buildDef = await buildClient.UpdateDefinitionAsync(buildDef);
return res.Id.ToString();
}

override python27Packages.bepasty-server

to experiment with upstream changes i want to alter the src= attribute in pkgs.python27Packages.bepasty-server.
reading through https://nixos.org/nixpkgs/manual/#chap-functions there is no example how to do this for pythonPackages!
so i have tried the stuff below, which i found in some xml-code for the documentation. but it doesn't work ... which is the part where i need your help!
packageOverrides
idea
nixpkgs.config.packageOverrides = super: {
python27Packages.bepasty-server = (pkgs.python27Packages.bepasty-server.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/bepasty/bepasty-server";
sha256 = "1ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
};
}));
results in this:
building Nix...
building the system configuration...
error: attribute ‘gunicorn’ missing, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/services/misc/bepasty.nix:5:14
(use ‘--show-trace’ to show detailed location information)
reducing the code
nixpkgs.config.packageOverrides = super: {
python27Packages.bepasty-server = pkgs.python27Packages.bepasty-server;
};
results in:
[root#nixdoc:~/nixpkgs]# nixos-rebuild build
building Nix...
building the system configuration...
error: attribute ‘gunicorn’ missing, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/services/misc/bepasty.nix:5:14
(use ‘--show-trace’ to show detailed location information)
so it seems this won't work at all, but why?
systemPackages
in contrast, here it seems to be working:
environment.systemPackages = with pkgs; [
(python27Packages.bepasty-server.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/bepasty/bepasty-server";
sha256 = "1ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
};
}))
file
# gcc-wrapper
gdb
gnumake
gnutls
psmisc
# tlspool
wireshark-cli
gnutls
however, i don't need bepasty-server binaries in the interactive environment but instead i need to override pkgs so the bepasty service will use it!
thanks to lassulus!
here is what works now:
nixpkgs.config.packageOverrides = super: {
pythonPackages = super.pythonPackages // { bepasty-server = super.python27Packages.bepasty-server.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/bepasty/bepasty-server";
sha256 = "9ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
#sha256 = "5ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
#sha256 = "7ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
};
});
};
};

Resources